[Bug 24861] New: [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

            Bug ID: 24861
           Summary: [Shadow]: Add a way to detect when the list of nodes
                    distributed to an insertion point mutates
           Product: WebAppsWG
           Version: unspecified
          Hardware: PC
                OS: Windows NT
            Status: NEW
          Severity: normal
          Priority: P2
         Component: Component Model
          Assignee: dglazkov@chromium.org
          Reporter: sorvell@chromium.org
        QA Contact: public-webapps-bugzilla@w3.org
                CC: mike@w3.org, public-webapps@w3.org
            Blocks: 14978

This is a common need. I believe it's the use case motivating this bug and it's
only stated here a bit more generally:

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


It has been suggested that MutationObservers provide the tools for doing this.
One could listen for a childList mutation on the shadowRoot.host (host A) and
then examine if any of the added/removed nodes are now in a particular <content
A> element's getDistributedNodes() list. However, this does not work with
reprojection. In this case, the host's child is <content B>. If the list of
nodes distributed to content B changes, the list of nodes distributed to
content A changes without causing a childList mutation on host A.

<host B>
  <div></div>
  SR B
    <host A>
      <content B></content>
      SR A
        <content A></content>
    </host>
</host>

In this case, to use MutationObservers to detect changes in content A's list of
distributed nodes, the developer would be forced to discover that changes to
host B's childList are relevant and also attach a MutationObserver to it. This
would be cumbersome in practice.

Here's an example that highlights this use case:

https://groups.google.com/forum/#!msg/polymer-dev/GMYzuuqlQ7k/U0tYEa-bYz0J


There are a variety of possible ways to address this. Some possibilities
include:

 - <content> element could fire an event when the nodes distributed to it
changes
 - a 'distributionList' mutation type could be added to MutationObservers,
which would function when a <content> is observed
 - <content> could provide a method to register a distribution changed
callback.

-- 
You are receiving this mail because:
You are on the CC list for the bug.

Received on Friday, 28 February 2014 15:52:55 UTC