DescriptionSupport slot element's fallback content feature
The spec discussion is:
- https://github.com/w3c/webcomponents/issues/317
The relevant algorithm sections in the Shadow DOM spec are:
- Distributed nodes algorithm: http://w3c.github.io/webcomponents/spec/shadow/#distributed-nodes-algorithm
- Composition algorithm: http://w3c.github.io/webcomponents/spec/shadow/#composition-algorithm
Now, if a slot does not have any assigned node, its child nodes are used as fallback contents.
This fallback ability will *chain* recursively. That means we can use *another* slot as a slot's fallback contents.
That gives us a great flexibility to compose a composed tree.
e.g.
Suppose we have the following tree of trees, which is borrowed from `v1-slots-fallback2.thml` test:
<div id='host'>
<template data-mode='open'>
<slot name='slot1'>
<div id='fallback1'></div>
<slot name='slot2'>
<div id='fallback2'></div>
</slot>
</slot>
<slot name='slot3'>
<slot name='slot4'>
<div id='fallback3'></div>
</slot>
</slot>
</template>
<div id='child1' slot='slot2'></div>
</div>
This can be composed into the following composed tree:
<div id='host'>
<div id='fallback1'></div>
<div id='child1'></div>
<div id='fallback3'></div>
</div>
The following feature is not yet supported:
- A slot API, HTMLSlotElement::getDistributedNodes does not work in a document tree nor v0 shadow tree
I'll support this as separate patches. This requires non-trivial changes to the distribution code.
Committed: https://crrev.com/b7c3414768afff35204a6c6b869c47d90d3953e0
Cr-Commit-Position: refs/heads/master@{#367789}
Patch Set 1 #Patch Set 2 : wip #Patch Set 3 : wip #
Total comments: 8
Patch Set 4 : addressed #Messages
Total messages: 39 (16 generated)
|