Re: [webcomponents] [Shadow] activeElement behavior seems to break encapsulation (#358)

Thanks. Let me add an example, which came from our previous our internal discussion, slightly modified to use slots elements:

Example
----

document tree:
```html
<body>
  <focusable1></focusable1>
    <x-foo>
      <focusable2 slot=slot1></focusable2>   // This is assigned to an slot
      <focusable3></focusable3>   // This is not assigned to any slots
    <x-foo>
</body>
```

x-foo's shadow tree:
```html
  <div>
    <slot name=slot1></slot>  // <- focusable2 is assigned to this slot
  </div>
  <focusable4></focusable4>
```

A) The behavior what the current spec says:
----

1. When focusable1 is focused:
   - a) document.activeElement -> focusable1
   - b) x-foo.shadowRoot.activeElement -> focusable1 (This spec bug was introduced when I refactored the spec.. My bad. :( My intention was that it should be null.

2. When focusable2 is focused:
    - a) document.activeElement -> focusable2
    - b) x-foo.shadowRoot.activeElement -> focusable2

3. focusable3 can't be focused. Thus, let's skip this case.

4. When focusable4 is focused:
    - a) document.activeElement -> x-foo
    - b) x-foo.shadowRoot.activeElement -> focusable4


B) The proposed change, as far as I understand correctly:
----

1. When focusable1 is focused:
    - a) document.activeElement -> focusable1
    - b) x-foo.shadowRoot.activeElement -> null

2. When focusable2 is focused:
    - a) document.activeElement -> focusable2
    - b) x-foo.shadowRoot.activeElement -> null

3. focusable3 can't be focused. Let's skip this case.

4. When focusable4 is focused:
    - a) document.activeElement -> x-foo
    - b) x-foo.shadowRoot.activeElement -> focusable4


I do not have a strong opinion. I'm fine with B. It looks very simple. 
We do not need to use a composed tree to determine shadowRoot.activeElement. We can tell activeElement by only taking a look at a static structure of tree of trees.

Does someone have any use cases where web developers would have trouble with B??
If there is none, I'm okay to update the spec with B.

---
Reply to this email directly or view it on GitHub:
https://github.com/w3c/webcomponents/issues/358#issuecomment-168970241

Received on Tuesday, 5 January 2016 10:50:26 UTC