mirror of https://github.com/vuejs/core.git
fix(custom-element): fix custom-element double render on immediate prop change
fix #9885 close #11335
This commit is contained in:
parent
1058ce8e74
commit
978ff3c1db
|
@ -2352,13 +2352,13 @@ function baseCreateRenderer(
|
||||||
namespace,
|
namespace,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
container._vnode = vnode
|
||||||
if (!isFlushing) {
|
if (!isFlushing) {
|
||||||
isFlushing = true
|
isFlushing = true
|
||||||
flushPreFlushCbs()
|
flushPreFlushCbs()
|
||||||
flushPostFlushCbs()
|
flushPostFlushCbs()
|
||||||
isFlushing = false
|
isFlushing = false
|
||||||
}
|
}
|
||||||
container._vnode = vnode
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const internals: RendererInternals = {
|
const internals: RendererInternals = {
|
||||||
|
|
|
@ -108,6 +108,7 @@ describe('defineCustomElement', () => {
|
||||||
myInputEl.removeAttribute('value')
|
myInputEl.removeAttribute('value')
|
||||||
await nextTick()
|
await nextTick()
|
||||||
expect(inputEl.value).toBe('')
|
expect(inputEl.value).toBe('')
|
||||||
|
app.unmount()
|
||||||
})
|
})
|
||||||
|
|
||||||
test('should not unmount on move', async () => {
|
test('should not unmount on move', async () => {
|
||||||
|
@ -772,4 +773,33 @@ describe('defineCustomElement', () => {
|
||||||
)
|
)
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
|
// #9885
|
||||||
|
test('avoid double mount when prop is set immediately after mount', () => {
|
||||||
|
customElements.define(
|
||||||
|
'my-input-dupe',
|
||||||
|
defineCustomElement({
|
||||||
|
props: {
|
||||||
|
value: String,
|
||||||
|
},
|
||||||
|
render() {
|
||||||
|
return 'hello'
|
||||||
|
},
|
||||||
|
}),
|
||||||
|
)
|
||||||
|
createApp({
|
||||||
|
render() {
|
||||||
|
return h('div', [
|
||||||
|
h('my-input-dupe', {
|
||||||
|
onVnodeMounted(vnode) {
|
||||||
|
vnode.el!.value = 'fesfes'
|
||||||
|
},
|
||||||
|
}),
|
||||||
|
])
|
||||||
|
},
|
||||||
|
}).mount(container)
|
||||||
|
expect(container.children[0].children[0].shadowRoot?.innerHTML).toBe(
|
||||||
|
'hello',
|
||||||
|
)
|
||||||
|
})
|
||||||
})
|
})
|
||||||
|
|
Loading…
Reference in New Issue