Last active
August 29, 2015 14:20
-
-
Save sorvell/e201c25ec39480be66aa to your computer and use it in GitHub Desktop.
Minimum viable imperative distribution
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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'); | |
} | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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