From a5929ff64f56951ea6ec605bed7972e42e8e53be Mon Sep 17 00:00:00 2001
From: Takayoshi Kochi
Date: Mon, 29 Aug 2016 17:27:55 +0900
Subject: [PATCH] Fix #556, make focus navigation work when shadow host's
tabindex is -1
The Shadow DOM spec section 6.3 (sequential focus navigation)
unintentionally excluded all shadow hosts with nagative tabindex in Step
3.1.3. This was unexpected for shadow hosts with `delagatesFocus=false`
shadow root.
Before:
- Exclude all shadow hosts with tabindex < 0
After:
- Allow shadow hosts with tabindex < 0, but only when
`delegatesFocus=false`
- In sorting by tabindex, treat such shadow hosts as `tabindex=0`
- Exclude those shadow hosts in Step 4.
---
spec/shadow/index.html | 14 ++++++++++----
1 file changed, 10 insertions(+), 4 deletions(-)
diff --git a/spec/shadow/index.html b/spec/shadow/index.html
index 2fbfa07e..04a1ad73 100644
--- a/spec/shadow/index.html
+++ b/spec/shadow/index.html
@@ -1153,7 +1153,7 @@ Focus
When HOST is focused by focus()
method or autofocus
attribute: The first focusable area in focus navigation order of HOST's shadow root's focus navigation scope gets focus. See the next section for the formal definition of the ordering.
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 focus navigation order of HOST's shadow root's focus navigation scope gets focus. See the next section for the formal definition of the ordering.
When any element in HOST's shadow tree has focus, :focus
pseudo-class applies to HOST in addition to the focused element itself.
- 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.
+ 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.
@@ -1260,9 +1260,15 @@ Sequential Focus Navigation
Let NAVIGATION-ORDER be an empty list.
For each element ELEMENT in a focus navigation scope SCOPE,
- - if ELEMENT is focusable, a shadow host, or a slot element, append ELEMENT to NAVIGATION-ORDER.
+ - If ELEMENT is a shadow host:
+
+ - If its tabindex value is not negative and its shadow root's delegatesFocus flag is set, append ELEMENT to NAVIGATION-ORDER.
+ - Otherwise, append ELEMENT to NAVIGATION-ORDER.
+
+
+ - Otherwise if ELEMENT is focusable, or a slot element, and its tabindex value is not negative, append ELEMENT to NAVIGATION-ORDER.
- Reorder NAVIGATION-ORDER according to the tabindex value attached to each node. In this step, an element whose tabindex value is negative must not be appended to NAVIGATION-ORDER.
+ Reorder NAVIGATION-ORDER according to the tabindex value attached to each node. In this step, a shadow host with negative tabindex value must be treated as if its tabindex value were 0.
@@ -1284,7 +1290,7 @@ Sequential Focus Navigation
- If ELEMENT is a shadow host:
- - Unless its shadow root’s delegatesFocus flag is set, append ELEMENT to MERGED-NAVIGATION-ORDER.
+ - If it is focusable, its tabindex value is not negative, and its shadow root’s delegatesFocus flag is not set, append ELEMENT to MERGED-NAVIGATION-ORDER.
- Apply the focus navigation order merging algorithm with the focus navigation order owned by its shadow root as input, then append the result to MERGED-NAVIGATION-ORDER.