Skip to content

Support Shadow DOM registries #3

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

Closed
bedeoverend opened this issue Jan 6, 2017 · 6 comments
Closed

Support Shadow DOM registries #3

bedeoverend opened this issue Jan 6, 2017 · 6 comments

Comments

@bedeoverend
Copy link
Collaborator

Given the MutationObserver targets the main document, it won't observe mutations inside any Shadow Tree. It's a bit of a niche, but be interested to see whether it's worthwhile supporting.

As far as I can tell, it would take just changing this line to be var root = document; rather than document.documentElement

I don't believe there's any repercussions, given the MO target just needs to be a Node? Then you can pass a Shadow Tree or any document fragment to the CustomAttributeRegistry constructor.

That would also mean having to make the CustomAttributeRegistry class public to define your own registries.

Thoughts?

@matthewp
Copy link
Owner

Hey @bedeoverend sorry I missed this. I think you're definitely right.

@matthewp
Copy link
Owner

I'm not at a computer right now but plan to try this later.

@bedeoverend
Copy link
Collaborator Author

@matthewp no worries - see the PR I've made, I'm using it in something I'm working on, and works so far. Though haven't added any tests for it yet.

@trusktr
Copy link

trusktr commented Jan 27, 2019

Hello guys, I have the shadow boundary problem. I want to register some attributes, and I want them to work on all elements in the app (even if they are in a shadow root).

What's the recommended pattern to make this happen? Do I have to create the registry on each root and re-define the attribute for that root?

@matthewp
Copy link
Owner

I haven't attempted this personally. Is there not a way to make MutationObservers subtree work within a shadow element? If not, I guess customAttributes could be changed to traverse through .shadowRoot itself. Mind making another issue about this specific problem?

@trusktr
Copy link

trusktr commented Apr 22, 2019

Is there not a way to make MutationObservers subtree work within a shadow element?

Unfortunately MO subtree observation stops at the boundary and doesn't traverse into the shadow roots.

Mind making another issue about this specific problem?

Sure! #3

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

No branches or pull requests

3 participants