Hacker News new | ask | show | jobs
by megous 3223 days ago
Is it possible to nest custom elements? I suppose it should be, but how would it be seen in DOM?

<my-container> <some-child some-attr></some-child> </my-container>

How can I get notifications in my-container when someone from outside adds another child to it?

3 comments

Yes, it would be see by the DOM as Shadow DOM I believe. https://developers.google.com/web/fundamentals/architecture/...

You can get notifications through the mutation observer API: https://developer.mozilla.org/en-US/docs/Web/API/MutationObs...

I think MutationObserver[1] would be the with-the-grain answer here

[1] https://developer.mozilla.org/en-US/docs/Web/API/MutationObs...

You can emit normal events (they bubble up normally), you can use a notification bus, redux, whatever you want. And your elements are visible in DOM normally like all other elements.