Skip to content

Instantly share code, notes, and snippets.

@sorvell
Last active August 29, 2015 14:20
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sorvell/e201c25ec39480be66aa to your computer and use it in GitHub Desktop.
Save sorvell/e201c25ec39480be66aa to your computer and use it in GitHub Desktop.
Minimum viable imperative distribution
var shadow = host.createShadowRoot({
// called synchronously for each node *added* to shadow's distribution pool
// called sequentially for each content in shadow until `true` is returned.
shouldDistributeNodeToInsertionPoint: function(node, content) {
// to implement catch-all
return true;
// to implement <content select="...">
// return node.matches(content.getAttribute('select'));
// to implement <content slot="...">
// return node.getAttribute('slot') === content.getAttribute('slot');
}
});
// when the shadowRoot is two-way isolated, the callback gets read only proxy elements instead of real ones.
var shadow = host.createShadowRoot({
// called synchronously for each node *added* to shadow's distribution pool
// called sequentially for each content in shadow until `true` is returned.
shouldDistributeNodeToInsertionPoint: function(nodeProxy, contentProxy) {
// to implement catch-all
return true;
// to implement <content select="...">
// return nodeProxy.matches(contentProxy.getAttribute('select'));
// to implement <content slot="...">
// return nodeProxy.getAttribute('slot') === contentProxy.getAttribute('slot');
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment