- From: Anne van Kesteren <notifications@github.com>
- Date: Fri, 15 Apr 2016 06:18:38 -0700
- To: w3c/webcomponents <webcomponents@noreply.github.com>
- Message-ID: <w3c/webcomponents/issues/288/210461414@github.com>
Here is some pseudo-code I plan to adopt for the DOM Standard next week. Hopefully folks can take a look at it and hopefully it's understandable. I'm assuming that slotables have pointers to slots and slots hold a list of pointers to slotables and both need updating during mutations. Flattening is not calculated as that does not seem necessary. CSS and the `assignedNodes()` method can handle flattening by themselves. ``` insert The node is being inserted into a parent node that also has a shadow root -> let slot be findSlot(node) -> if slot is non-null: -> run assignSlotables(slot) // this is naive, but good enough for spec -> slotchange(slot) The node is being inserted into a parent node that is a slot -> assignSlotables(parent) -> if node's assigned slot is non-null, slotchange(node's assigned slot) An inclusive-descendant of node is a slot element -> for each _slot_ in node's tree // a new slot changes everything -> let current be _slot_'s assigned nodes -> assignSlotables(_slot) -> let new be _slot_'s assigned nodes -> if current != new and _slot_ was not just inserted, slotchange(_slot_) remove Node has an assigned slot -> slotchange(node's assigned slot) // recursive -> run assignSlotables(node's assigned slot) -> Assert: node's assigned slot is null Node has a slot element as inclusive-descendant -> for each _slot_ in node's tree: -> let current be _slot_'s asigned nodes -> assignSlotables(_slot_) -> let new be _slot_'s assigned nodes -> if current != new, slotchange(_slot_) -> for each _slot_ in oldParent's tree // spec calls this parent -> let current be _slot_'s asigned nodes -> assignSlotables(_slot_) -> let new be _slot_'s assigned nodes -> if current != new, slotchange(_slot_) slotable's slot attribute change -> if value == oldValue, return -> if node's assigned slot is non-null: -> assignSlotables(node's assigned slot) -> slotchange(node's assigned slot) -> Assert: node's assigned slot == null -> let slot be findSlot(node) -> if slot is non-null -> assignSlotables(slot) -> slotchange(slot) slot's name attribute change -> for each slot element _slot_ in slot element's tree -> let current be _slot_'s asigned nodes -> assignSlotables(_slot) -> let new be _slot_'s assigned nodes -> if current != new, slotchange(_slot_) ``` Obviously there's a bit of copypasta here that can be (and will be in the spec) reduced with extra algorithms. --- You are receiving this because you are subscribed to this thread. Reply to this email directly or view it on GitHub: https://github.com/w3c/webcomponents/issues/288#issuecomment-210461414
Received on Friday, 15 April 2016 13:19:06 UTC