Skip to content
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

Merged
merged 4 commits into from May 23, 2017

Conversation

dreamofabear
Copy link

Follow-up to #9426.

/to @jridgewell @camelburrito

src/dom.js Outdated
break;
}
} while (true);
return (n instanceof Document);
Copy link
Contributor

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?)

Copy link
Author

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);
Copy link
Contributor

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

Copy link
Contributor

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

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Author

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),
Copy link
Contributor

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.

Copy link
Author

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

@dreamofabear
Copy link
Author

@jridgewell @camelburrito Any other comments?

@dreamofabear
Copy link
Author

Thanks!

@dreamofabear dreamofabear merged commit 5600cec into ampproject:master May 23, 2017
@dreamofabear dreamofabear deleted the shadow-slides-assert branch May 23, 2017 22:49
jridgewell added a commit to jridgewell/amphtml that referenced this pull request Mar 13, 2018
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.
jridgewell added a commit to jridgewell/amphtml that referenced this pull request Mar 14, 2018
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.
jridgewell added a commit that referenced this pull request Mar 16, 2018
* Handle connectedCallback when disconnected

Fixes #12849.
Reverts part of #9432, since the bug is being addressed in runtime.
Closes #9441, since root bug is being addressed.

* Protect against async disconnectedCallback, too

* Tests

* lint
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants