From e1725be10b028d9bb94145d896614c3ef18f1d79 Mon Sep 17 00:00:00 2001 From: Takayoshi Kochi Date: Wed, 23 Mar 2016 18:00:02 +0900 Subject: [PATCH 1/2] Add delegatesFocus in the Shadow DOM spec. Original proposal: https://github.com/w3c/webcomponents/blob/gh-pages/proposals/ShadowRoot-delegatesFocus-Proposal.md --- spec/shadow/index.html | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/spec/shadow/index.html b/spec/shadow/index.html index bffffb58..45fa6a75 100644 --- a/spec/shadow/index.html +++ b/spec/shadow/index.html @@ -1132,6 +1132,20 @@

Ranges and Selections

The getSelection() method of the shadow root object returns the current selection in this shadow tree.

+
+

Focus

+

A shadow host can delegate focus to its shadow root by assigning a boolean delegatesFocus flag to be true in ShadowRootInit dictionary. If omitted, a shadow host does not delegate focus to its shadow root, and the shadow host itself can be focusable.

+

When a shadow host delegates focus, user agent must behave as follows. +

    +
  1. When the shadow host is being focused by TAB focus navigation: if the direction is forward, the first focusable element in its shadow tree gets focuse. If the direction is backward, the last focusable element in its shadow tree gets focuse. If there is no focusable element in its shadow tree, the shadow host is skipped for the navigation. See the next secition for the formal definition.
  2. +
  3. When the shadow host is being focused by focus() method or autofocus attribute: The first focusable element in its shadow tree gets focus.
  4. +
  5. When non-focusable area in its shadow tree is clicked: The first focusable element in its shadow tree gets focus.
  6. +
  7. When a focusable element in its shadow tree is clicked: The element itself gets focus.
  8. +
  9. When any of its shadow tree has focus, :focus pseudo-class on the shadow host matches.
  10. +
+

+
+

Focus Navigation

@@ -1454,6 +1468,8 @@

ShadowRootInit dictionary

required ShadowRootMode mode
Specifies the associated mode of ShadowRoot
+
boolean delegatesFocus
+
Specifies whether shadow host delegates focus to its ShadowRoot. If omitted, the default value is false.
From 6ff9e62c5ad48e5d4f69b6319ff5c81bfa8debd2 Mon Sep 17 00:00:00 2001 From: Takayoshi Kochi Date: Thu, 31 Mar 2016 19:36:24 +0900 Subject: [PATCH 2/2] Clearer definition for delegatesFocus behavior. --- spec/shadow/index.html | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/spec/shadow/index.html b/spec/shadow/index.html index 06fbb96e..54f078e3 100644 --- a/spec/shadow/index.html +++ b/spec/shadow/index.html @@ -1118,14 +1118,14 @@

Ranges and Selections

Focus

-

A shadow host can delegate focus to its shadow root by assigning a boolean delegatesFocus flag to be true in ShadowRootInit dictionary. If omitted, a shadow host does not delegate focus to its shadow root, and the shadow host itself can be focusable.

-

When a shadow host delegates focus, user agent must behave as follows. +

A shadow host can delegate focus to its shadow root by assigning a boolean delegatesFocus flag to be true in ShadowRootInit dictionary. If omitted, a shadow host does not delegate focus to its shadow root, and the shadow host itself can be focusable.

+

When a shadow host HOST delegates focus, user agent must behave as follows.

    -
  1. When the shadow host is being focused by TAB focus navigation: if the direction is forward, the first focusable element in its shadow tree gets focuse. If the direction is backward, the last focusable element in its shadow tree gets focuse. If there is no focusable element in its shadow tree, the shadow host is skipped for the navigation. See the next secition for the formal definition.
  2. -
  3. When the shadow host is being focused by focus() method or autofocus attribute: The first focusable element in its shadow tree gets focus.
  4. -
  5. When non-focusable area in its shadow tree is clicked: The first focusable element in its shadow tree gets focus.
  6. -
  7. When a focusable element in its shadow tree is clicked: The element itself gets focus.
  8. -
  9. When any of its shadow tree has focus, :focus pseudo-class on the shadow host matches.
  10. +
  11. In sequential focus navigation, HOST itself will be skipped. See the next secition for the formal definition.
  12. +
  13. When HOST is focused by focus() method or autofocus attribute: The first focusable area in the tree order in HOST's shadow tree gets focus.
  14. +
  15. When mouse is clicked on a node in HOST's shadow tree and the node is not a focusable area: The first focusable area in the tree order in HOST's shadow tree gets focus.
  16. +
  17. When any element in HOST's shadow tree has focus, :focus pseudo-class applies to HOST in addition to the focused element itself.
  18. +
  19. If :focus pseudo-class applies to HOST, and HOST is in a shadow root of another shadow host HOST2 which also delegates focus, :focus pseudo-class applies to HOST2 as well.

@@ -1581,7 +1581,7 @@

ShadowRootInit dictionary

required ShadowRootMode mode
Specifies the associated mode of ShadowRoot
-
boolean delegatesFocus
+
boolean delegatesFocus = false
Specifies whether shadow host delegates focus to its ShadowRoot. If omitted, the default value is false.