Re: [w3c/webcomponents] Need "slotchange" event (#288)

Thanks. I have reviewed "insert" part. Let me review other parts later.

It looks that there is an assumption that we preserve the result of assgnSlottables(slot) somewhere.
In other words, before running each algorithms, we can assume that each slot's "assingned nodes" are always *up-to-date*, right?

```
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)
```

How slotchange(slot) can be defined? I think that should be recursive, like:

```
function slotchanged(slot):
  enqueue_slotchange_event_if_it_is_not_enquened_for(slot);
  let slot2 = fildSlot(slot):
  if slot2 != null:
     slotchanged(slot2)
```

Does this match your expectation?

Ops. I am afraid that this slotchanged(slot) is still not enough because a slot might be a fallback content of another slot. That makes the situation complex. We need additional check:

```
function slotchanged(slot):
  enqueue_slotchange_event_if_it_is_not_enquened_for(slot);
  let slot2 = findSlot(slot):
  if (slot2 != null):
     slotchanged(slot2)
  else if (slot's parent is slot) and (slot's parent's assigned nodes are empty):
     slotchanged(slot's parent)
```

--

```
  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)
```
The node is never *assigned* to the parent slot, according to the definition.
It can be a member of distributed nodes, as a fallback content, but it is not *assigned* to the parent, by definition. Thus, these should be:

```
  The node is being inserted into a parent node that is a slot
    -> if parent's assigned nodes are empty, slotchange(parent)
```

--

```
  An inclusive-descendant of node is a slot element
    -> for each _slot_ in node's tree // a new slot changes everything
```

This should be in tree order (which is implicit?) to make sure that assignSlottables(slot-A) is called before assignSlottables(slot-B-which-is-a-descendant-of-A) is called. That is required to handle the fallback contents correctly.


---
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-211278879

Received on Monday, 18 April 2016 08:56:27 UTC