-
-
Notifications
You must be signed in to change notification settings - Fork 8.9k
Description
Vue version
3.4.21
Link to minimal reproduction
Steps to reproduce
- click move button, then delete the two digits in input, will find 0 in input
- or click move, then click removeAttr, value attr of custom-element is removed, but inner input is not updated
What is expected?
MutationObserver in custom element should work after we move the element, then the prop can be updated normally
What is actually happening?
MutationObserver is disconnected if we move the DOM.
For the first situation, we delete the two digits, the num will be null, but patchDOMProp(rumtime-dom) will make it 0 and remove the value attribute. If MutationObserver is still on, inner value will be null as the attribute is removed. But it's off so we get 0
System Info
No response
Any additional comments?
I am doing some work with documentPictureInPicture, which can open a new small top-level window to display any elements. So I have to move the elements from original document to the new document, then the issue occurs.
I think we can put the clear logic of MutationObserver in next tick of disconnectedCallback of apiCustomElement(@vue/runtime-dom), then it will work
disconnectedCallback() {
this._connected = false
- if (this._ob) {
- this._ob.disconnect()
- this._ob = null
- }
nextTick(() => {
if (!this._connected) {
+ if (this._ob) {
+ this._ob.disconnect()
+ this._ob = null
+ }
render(null, this.shadowRoot!)
this._instance = null
}
})
}