From cf152ed339c4fba1e8d8b8d610ad2c81f4daaec1 Mon Sep 17 00:00:00 2001 From: Nolan Lawson Date: Thu, 15 Sep 2022 16:13:12 -0700 Subject: [PATCH] Add steps for shadow roots and slots Fixes #51 and #20. Clarifies how accessible names are calculated for shadow roots and slots. --- index.html | 22 ++++++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) diff --git a/index.html b/index.html index 497fe48..c201d31 100644 --- a/index.html +++ b/index.html @@ -224,6 +224,8 @@

Terminology

The DOM [=nodes|node=] or [=element=] for which the text alternative is sought.
Current node
The DOM [=nodes|node=] currently traversed to compute the root node's text equivalent. Initially, the current node is the root node, but at later stages is either some descendant of the root node, or another referenced node.
+
Displayed child nodes
+
The DOM [=nodes=] that are rendered as child nodes of a given node when taking [=shadow root|shadow roots=] and [=slot|slots=] into consideration.
Flat string
A string of characters where all carriage returns, newlines, tabs, and form-feeds are replaced with a single space, and multiple spaces are reduced to a single space. The string contains only character data; it does not contain any markup.
Total accumulated text
@@ -394,11 +396,23 @@

Computation steps

  • For :after pseudo elements, User agents MUST append CSS textual content, without a space, to the textual content of the current node.
  • -
  • For each child node of the current node: +
  • + Determine the displayed child nodes of the current node:
      -
    1. Set the current node to the child node.
    2. -
    3. Compute the text alternative of the current node beginning with step 2. Set the result to that text alternative.
    4. -
    5. Append the result to the accumulated text.
    6. +
    7. If the current node has an attached [=shadow root=], set the displayed child nodes to be the child nodes of the [=shadow root=].
    8. +
    9. Otherwise, if the current node is a [=slot=] with [=slot/assigned nodes=], set the displayed child nodes to be the [=slot/assigned nodes=] of the current node.
    10. +
      + Comment: +

      A [=slot=] with [=slot/assigned nodes=] displays those nodes; otherwise it displays its default content, i.e. its child nodes.

      +
      +
    11. Otherwise, set the displayed child nodes to be the child nodes of the current node.
    12. +
    +
  • +
  • For each displayed child node of the displayed child nodes of the current node: +
      +
    1. Set the current node to the displayed child node.
    2. +
    3. Compute the text alternative of the current node beginning with step 2. Set the result to that text alternative.
    4. +
    5. Append the result to the accumulated text.
  • Return the accumulated text if it is not the empty string ("").