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

Add isContainedWithin function for ShadowRoots #1374

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

alexalekseyenko
Copy link
Contributor

Previously, el.contains(e) would return false if e was inside ShadowRoots. If el.contains(e) returns false, isContainedWithin(e, el) will instead check e's root, and the root's root, and so on, until either contains returns true or the top of the tree is reached.

Previously, `el.contains(e)` would return `false` if `e` was inside ShadowRoots. If `el.contains(e)` returns `false`, `isContainedWithin(e, el)` will instead check `e`'s root, and the root's root, and so on, until either `contains` returns `true` or the top of the tree is reached.
@alexalekseyenko
Copy link
Contributor Author

Regarding the other two instances of contains in utils.js:

if (elementWithHref && elementWithHref !== e && elementWithHref.contains(e)) {

if (!elements[i].contains(last(result))

presumably we could run into the same issue with ShadowRoots, but I don't know if I've encountered it in the wild yet, so I thought it might be best to keep the change smaller for now.

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

Successfully merging this pull request may close these issues.

1 participant