[Bug 24861] [Shadow]: Add a way to detect when the list of nodes distributed to an insertion point mutates

https://www.w3.org/Bugs/Public/show_bug.cgi?id=24861

--- Comment #4 from Elliott Sprehn <esprehn@gmail.com> ---
We should add a Mutation(In reply to Daniel Buchner from comment #3)
> (In reply to Olli Pettay from comment #2)
> > (In reply to Elliott Sprehn from comment #1)
> > > We also need to be able to detect when an element gets a ShadowRoot since
> > > that's conceptually like an "appendChild" like operation.
> > Why would we need that. That is yet another way to expose more
> > internals of shadow dom management to the outer world, and we should
> > make encapsulation better, by default, not worse.
> 
> There are many, many cases where this functionality is essential - I'll
> illustrate one I have faced:
> 
> A while back, I worked on a component that wrapped up drag and drop into a
> simple, declarative tag, <x-dragbox>. The component subscribed to all the
> drag/drop events, and allowed children of certain kinds to be draggable
> within it. The catch is that in order to "turn on" the DOM's drag/drop
> functionality for an element, you must first add the boolean attribute,
> draggable="".
> 
> For obvious reasons, this sucks. Instead of a simple, async event that keyed
> off the select="" filter for my allowed, draggable node types, it required
> me to setup a significant chunk of boilerplate using Mutation Observers and
> a redundant node filter. All this just so I could intercept added nodes and
> append the draggable="" attribute.
> 
> There are many more examples where this feature would dramatically reduce
> code complexity and boilerplate. (also note: MO's are on the 'advanced' side
> in terms of web API experience/difficulty, so it's not simple boilerplate
> for a huge percentage of web devs)

This has come up again for us too. It's critical for global page observing
libraries and extensions like yours.

For example recently we removed beforeload events in Chrome and asked
developers to use MutationObservers to watch for DOM mutations, but since they
can't watch for ShadowRoots they end up not working in all the new web
component based content. Similarly there's polyfill and behavior libraries that
want to watch for global attributes on elements and previously could use
MutationObserver, but can't because the content is inside a ShadowRoot.

Lets add a shadowRoots MutationObserverInit option.

-- 
You are receiving this mail because:
You are the QA Contact for the bug.

Received on Thursday, 26 June 2014 21:44:07 UTC