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
Assert slide parent is connected #9432
Assert slide parent is connected #9432
Conversation
9bfb9a5
to
c42a7da
Compare
src/dom.js
Outdated
break; | ||
} | ||
} while (true); | ||
return (n instanceof Document); |
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.
how bad is this for performance - should we add guidelines of when/whom should use this? (may be add a presubmit review hook?)
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 don't think it's much worse than closestNode
etc. that walk up the ancestor chain.
src/dom.js
Outdated
break; | ||
} | ||
} while (true); | ||
return (n instanceof Document); |
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.
instanceof
has bug when crossing boundaries. Instead, use n.nodeType == 9
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.
@jridgewell wow that is interesting! could you share if you have any reading material on this
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.
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.
Good to know, though this shouldn't cross iframe boundary. Done.
@@ -186,6 +187,8 @@ export class AmpSlideScroll extends BaseSlides { | |||
|
|||
// Slides must only be re-parented to DOM-connected nodes to avoid | |||
// errors when used in a shadow document (#9291). | |||
dev().assert(isConnectedNode(slideWrapper), |
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'll probably affect everything that reparents.
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.
Fair, created an issue to investigate: #9441
@jridgewell @camelburrito Any other comments? |
Thanks! |
Fixes ampproject#12849. Reverts part of ampproject#9432, since the bug is being addressed in runtime. Closes ampproject#9441, since root bug is being addressed.
Fixes ampproject#12849. Reverts part of ampproject#9432, since the bug is being addressed in runtime. Closes ampproject#9441, since root bug is being addressed.
Follow-up to #9426.
/to @jridgewell @camelburrito