(function(scope) {

scope = scope || {};

var unShadow = {
  createShadowDom: function(inInstance, inContent) {
    // memoize lightDom (sort of)
    inInstance.lightDom = inInstance;
    // create shadowRoot
    var shadowRoot = document.createElement("shadow-root");
    shadowRoot.style.cssText = "display: none;";
    shadowRoot.content = inContent;
    // add to internal shadow stack
    inInstance.shadows = inInstance.shadows || [];
    inInstance.shadows.push(shadowRoot);
    if (scope.flags.showshadow) {
      // for debug/visualization purposes only
      // install shadow root on instance
      inInstance.appendChild(shadowRoot);
      // with a copy of its content
      shadowRoot.appendChild(inContent.cloneNode(true));
    }
    // cache the shadowDom instance
    inInstance.shadowRoot = shadowRoot;
    return inInstance;
  },
  installDom: function(inInstance) {
    // create a source we can extract nodes from
    var source = inInstance;
    // target for installation
    var target = inInstance;
    // get all shadow roots
    var shadowRoots = target.querySelectorAll("shadow-root");
    // shadow dom
    var shadowRoot = inInstance.shadowRoot;
    if (shadowRoot) {
      // create mutable shadowDom
      var dom = shadowRoot.content;
      // build a immutable list of template <content> elements
      var c$ = [];
      $$(dom, "content").forEach(function(content) {
        c$.push(content)
      });
      // replace each <content> element with matching content
      c$.forEach(function(content) {
        // build a fragment to contain selected nodes
        var frag = document.createDocumentFragment();
        // find selected 'light dom' nodes
        var slctr = content.getAttribute("select");
        var nodes = slctr ? $$(source, slctr) : source.childNodes;
        for (var i=0, n; (n=nodes[i]);) {
          if ((n.parentNode != source) || isTemplate(n) || isShadowRoot(n)) {
            i++;
          } else {
            frag.appendChild(n);
          }
        }
        // replace the content node with the fragment
        content.parentNode.replaceChild(frag, content);
      });
    } else {
      dom = document.createDocumentFragment();
      for (var n; (n=source.childNodes[0]);) {
        dom.appendChild(n);
      }
    }
    // install constructed dom
    target.textContent = '';
    if (scope.flags.showshadow) {
      // for visualizing shadow roots only
      for (i=0, n; n=shadowRoots[i]; i++) {
        target.appendChild(n);
      }
    }
    target.appendChild(dom);
  },
  observe: function(inInstance, inDecl) {
    var contentChanges = function() {
      unShadow.installDom(inInstance);
    };
    var observer = new WebKitMutationObserver(contentChanges);
    observer.observe(inInstance.lightDom, {
      characterData: true,
      childList: true,
      subtree: true
    });
  }/*,
  renderShadows: function(inDom, inDecl) {
    // if this template dom has a <shadow> node
    var shadow = $(inDom, "shadow");
    if (shadow) {
      // fetch the shadow dom that would be rendered
      // by my ancestors (recusively)
      var srcShadow = unShadow.fetchShadow(inDecl.ancestor);
      if (srcShadow) {
        shadow.parentNode.replaceChild(srcShadow, shadow);
      }
    }
    return inDom;
  },
  fetchShadow: function(inDecl) {
    // find ancestor template
    var d = inDecl;
    while (d && !d.shadow) {
      d = d.ancestor;
    }
    // now render any ancestor shadow DOM (recurse)
    return d && unShadow.renderShadows(d.shadow, d);
  }
  */
};

var isTemplate = function(inNode) {
	return (inNode.tagName == "TEMPLATE");
};

var isShadowRoot = function(inNode) {
  return (inNode.tagName == "SHADOW-ROOT");
};

// exports

scope.unShadowImpl = unShadow;

})(window.__exported_components_polyfill_scope__);

@@ -890,49 +890,34 @@
  // 
-create a source we can extract nodes from
+source nodes to distribute
 %0A   
@@ -964,16 +964,16 @@
 for 
-installa
+distribu
 tion
@@ -1006,98 +1006,8 @@
 ce;%0A
-    // get all shadow roots%0A    var shadowRoots = target.querySelectorAll(%22shadow-root%22);%0A
     
@@ -1098,23 +1098,8 @@
   //
- create mutable
  sha
@@ -1104,16 +1104,17 @@
 hadowDom
+ 
 %0A      v
@@ -1138,24 +1138,79 @@
 ot.content;%0A
+      // projections array%0A      var projections = %5B%5D;%0A
       // bui
@@ -1213,16 +1213,17 @@
  build a
+n
  immutab
@@ -1922,24 +1922,57 @@
 ndChild(n);%0A
+            projections.push(n);%0A
           %7D%0A
@@ -2246,46 +2246,284 @@
     
-%7D%0A    %7D%0A    // install constructed dom
+  projections.push(n);%0A      %7D%0A    %7D%0A    //%0A    if (scope.flags.showshadow) %7B%0A      // for visualizing shadow roots only%0A      // cache all shadow roots%0A      var shadowRoots = target.querySelectorAll(%22shadow-root%22);%0A    %7D%0A    //%0A    // we want to replace any existing content
 %0A   
@@ -2548,16 +2548,23 @@
 t = '';%0A
+    //%0A
     if (
@@ -2628,24 +2628,54 @@
  roots only%0A
+      // restore shadow roots%0A
       for (i
@@ -2759,31 +2759,112 @@
     
-target.appendChild(dom)
+//%0A    // install constructed dom%0A    target.appendChild(dom);%0A    target.distributedNodes = projections
 ;%0A  

build distributedNodes array