New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Bypass isConnected checks when destroying FIE #17890
Conversation
This may be the cause of all the "window is null" bugs...
src/custom-element.js
Outdated
* Called when an element is disconnected from DOM, or when an ampDoc is | ||
* being disconnected (the element itself may still be connected to ampDoc). | ||
* | ||
* This does not guard against connected elements. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is confusing since we still check this.isConnected_
. Maybe rename that variable to connectedCallbackWasCalled_
?
src/custom-element.js
Outdated
* | ||
* This does not guard against connected elements. | ||
*/ | ||
disconnect() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think using opt_force = false
or opt_checkDom = true
param in disconnectedCallback
is more readable. Then add a comment to resource.js about why we pass false in that case.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
@jridgewell @choumx is this PR important enough to cherry pick into the current release before promoting to production? All of these referenced issues are present in current canary at relatively high error rates. |
* Bypass isConnected checks when destroying FIE This may be the cause of all the "window is null" bugs... * Tests and reviews
This may be the cause of all the "window is null" bugs...
Introduced in #13945, we started to ignore
disconnectedCallback
s when the node itself was still connected to a document. But, FIE's destroy themselves and try to clean upResource
s even though those resources are still connected to the FIE's document. So, we would end up ignoring the disconnect, leaving all of them in memory and active.Fixes #17839.
Fixes #15883.
Fixes #17604.
Probably more... Anything that touches FIE.
Fixes (maybe) #9177?
Fixes (maybe) #17840?
Working on tests now.