[Bug 21149] [Shadow]: Shadow DOM-based components could benefit from a way to detect when light DOM contents change

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

Dominic Cooney <dominicc@chromium.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |dominicc@chromium.org

--- Comment #1 from Dominic Cooney <dominicc@chromium.org> ---
I was thinking about this problem recently. I think Mutation Observers would
work well for this, something like:

var host = ...;

// Create ShadowRoot
var shadow = host.createShadowRoot();

// Populate ShadowRoot
var template = ...;
shadow.appendChild(template.content);

// Observe light DOM changes
var observer = new MutationObserver(function (mutations) {
  // Distribution may have changed; do imperative updates
  [].forEach.call(shadow.querySelectorAll('content'), function (content) {
    // Use content.getDistributedNodes()
  });
});
observer.observe(host, { subtree: true, attributes: true, childList: true });

(This over-observes to make this code succinct, but it is possible to use two
observers to observe precisely what changes can affect distribution.)

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

Received on Thursday, 28 February 2013 21:36:43 UTC