Re: [whatwg/dom] Add Imperative Slot API (#966)

@mfreed7 commented on this pull request.

Ok, this should be updated with the new "weak pointer in both directions" logic. The intention was:

 - you can call `slot.assign()` at any time with any nodes, regardless of where the nodes or the slot lives at the time.
 - Each node can be manually assigned to only a single `<slot>` at any time.
 - If a `<slot>` currently lives inside a shadow tree that is in "manual" mode, then any nodes in its manually assigned nodes list that are currently light-dom direct children of the shadow host will be slotted in. Any other manually assigned nodes that don't meet these criteria will not be slotted, but will also not be removed from the list.
 - If a `<slot>` with manually assigned nodes currently lives inside a shadow tree that is in "name" mode, the manually assigned nodes will be ignored, and nodes will be assigned based on normal "name" assignment rules. Again, nodes will not be removed from the list here.
 - Given the above, both slots and nodes should be able to be moved around the tree and among documents without destroying the slot-to-node relationships established by `slot.assign()`. Nodes will be (re-)assigned to slots if/when they meet the criteria above.

> @@ -2175,6 +2175,11 @@ Unless stated otherwise it is null. A <a>slottable</a> is
 <dfn export for=slottable id=slotable-assigned>assigned</dfn> if its <a>assigned slot</a> is
 non-null.</p>
 
+<p>A <a>slottable</a> has an associated
+<dfn export for=slottable id=slottable-manual-slot-assignment>manual slot assignment</dfn> (null
+or a <a>slot</a>). Unless stated otherwise, it is null. The <a>manual slot assignment</a> is
+a weak reference to the slot, such that it can be garbage collected if not referenced elsewhere.</p>

Here also, comments appreciated on the "weak pointer" stuff.

> @@ -5729,6 +5755,9 @@ It is initially set to false.</p>
 <!-- If we ever change this, e.g., add a ShadowRoot object constructor, that would have serious
      consequences for innerHTML. -->
 
+<p><a for=/>Shadow roots</a> have an associated <dfn for=ShadowRoot>slot assignment</dfn>
+("<code>manual</code>" or "<code>name</code>").</p>

Did we bikeshed "name" vs. "named" at all here? Using "named" feels better to me for some reason, but no strong opinions.

-- 
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/whatwg/dom/pull/966#pullrequestreview-632761462

Received on Friday, 9 April 2021 20:31:38 UTC