Skip to content

Update auto-update-text-efbfc7.md #1959

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 2 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 12 additions & 29 deletions _rules/auto-update-text-efbfc7.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,7 @@ acknowledgments:

## Applicability

This rule applies to any [HTML element][] that has a [visible][] [text node][] as a [descendant][] in the [flat tree][], for which all the following is true:

- **changed:** the `innerText` property of the element changes multiple times within a 10 minute time span where there is no [user interaction][]; and
- **no child changed:** the element does not have [children][child] in the [flat tree][] whose `innerText` property also changes; and
- **not alone:** the element has an [ancestor][] element in the [flat tree][] with a non-empty `innerText` property whose value is different from the `innerText` of the test target.
This rule applies to any [HTML element][] that has one or more [visible][] [text nodes][] as [children][] in the [flat tree][], where the combined text from the [text nodes][] changes multiple times within a 10 minute time span where there is no [user interaction][].
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I currently have this including the possibility of multiple text nodes, we could potentially simplify this by using a normalized (https://dom.spec.whatwg.org/#dom-node-normalize) DOM, but that might make it unnecessarily more technical as well.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As far as I understand, normalising would collapse adjacent text nodes, but in something like <div>Lorem <span>Ipsum</span> Dolor</div>, the div has two text nodes (Lorem and Dolor) and they won't be collpased by normalisation (due to the span in the middle) 🤔

(also looks a bit like Text.wholeText)

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've been doing a bit of rule archaeology… The "innerText" formulation came after this discussion, and notably this example:

<div id="x"><b>Hello world</b></div>
<script>
setTimeout(() => document.querySelector('#x').innerHTML = '<i>Goodbye</i>', 1000)
</script>

Where the div is Applicable (and fails) in the current rule but would be Inapplicable in the new rule (it has no text content), and neither the b nor the i have text node children that changes (the i could as well be a new b, different from the existing one, with regular updates).


The actual move to use innerText seems to be this commit which was done apparently after some not archived discussion.
I have some blurry memories of the fact that even something like all our examples that use element.innerText = "foo" to update the text result in creating a new text node rather than updating the existing one. @carlosapaduarte @WilcoFiers do you remember anything else?

Then of course, the new Applicability uses "combined text" which sounds like a non-technical way to say innerText. I'd argue we'd need to define "combined text" more precisely, because in our examples where the text nodes are deleted and replaced by new ones, I'm not sure whether the "combined text from the text nodes" is changing. The innerText of the parent is changing, but we need to be unambiguous that "combined text of the text nodes" means "as seen from the parent point of view".


In any case, due to the first example in this comment, the change is a big change in Applicability, making the rule much less applicable. I'm not sure this is what we want.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I appreciate the rule archaeology, that does help me understand why the applicability was formulated like this. I am going to do some additional poking to see if there is a way to restate it to make it a bit simpler. At the very least (if i can't come up with anything) I would like to add a Note that discusses the context of no child changed and not alone, such as your comment above on where the not alone came from and then for no child changed how that localizes the target to the descendant closest to the changed text.

I figured I would need to define "combined text" in more definite terms. My intention is that it is calculated as the union of the text of all the text nodes of a parent( e.g., so if a parent has 3 text nodes a, b, and c, its combined text would be the union of text from a, b, c). This was my attempt to get rid of some of the tree traversal the no child changed condition brings with it. But your first example above using <b> or <i> invalidates that approach so I will have to go back to the drawing board on that.


## Expectation

Expand Down Expand Up @@ -77,7 +73,7 @@ The [instruments][instrument] used to pass this rule (if any), must meet all lev

#### Passed Example 1

This `span` element contains text content that is automatically **changed** multiple times without user intervention and there is a button available to stop the automatic changes. The rule is not applicable to the second `p` element because it has a **child changed** (the `span` element).
This `span` element contains text content that automatically changes multiple times without user intervention and there is a button available to stop the automatic changes. The rule is not applicable to the second `p` element because its child [text node][] is unchanged.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is where we need to be clear about what "contains text content" means.
The span has text nodes that change (are replaced by other text nodes). But the actual data of the individual text nodes doesn't change (as far as I remember).

I guess we'll end up saying that "contains text content" refers to the innerText 🤔


```html
<body onload="startUpdates()">
Expand All @@ -95,7 +91,7 @@ This `span` element contains text content that is automatically **changed** mult

#### Passed Example 2

This `span` element contains text content that is automatically **changed** multiple times without user intervention and there is a button available to pause and resume the automatic changes. The rule is not applicable to the second `p` element because it has a **child changed** (the `span` element).
This `span` element contains text content that automatically changes multiple times without user intervention and there is a button available to pause and resume the automatic changes. The rule is not applicable to the second `p` element because its child [text node][] is unchanged.

```html
<body onload="startUpdates()">
Expand All @@ -113,7 +109,7 @@ This `span` element contains text content that is automatically **changed** mult

#### Passed Example 3

This `span` element contains text content that is automatically **changed** multiple times without user intervention and there is a button available to hide the automatically updating content. The rule is not applicable to the second `p` element because it has a **child changed** (the `span` element).
This `span` element contains text content that automatically changes multiple times without user intervention and there is a button available to hide the automatically updating content. The rule is not applicable to the second `p` element because its child [text node][] is unchanged.

```html
<body onload="startUpdates()">
Expand All @@ -131,7 +127,7 @@ This `span` element contains text content that is automatically **changed** mult

#### Passed Example 4

This `span` element contains text content that is automatically **changed** multiple times without user intervention and there is an [instrument][] available to modify the frequency of the changes. The rule is not applicable to the second `p` element because it has a **child changed** (the `span` element).
This `span` element contains text content that automatically changes multiple times without user intervention and there is an [instrument][] available to modify the frequency of the changes. The rule is not applicable to the second `p` element because its child [text node][] is unchanged.

```html
<body onload="startUpdates()">
Expand All @@ -151,7 +147,7 @@ This `span` element contains text content that is automatically **changed** mult

#### Passed Example 5

This `span` element contains text content that is automatically **changed** multiple times without user intervention and the location of an [instrument][] to control the changes is clearly available.
This `span` element contains text content that automatically changes multiple times without user intervention and the location of an [instrument][] to control the changes is clearly available. The rule is not applicable to the second `p` element because its child [text node][] is unchanged.

```html
<body onload="startUpdates()">
Expand Down Expand Up @@ -199,7 +195,7 @@ This `span` element contains text content that is automatically **changed** mult

#### Failed Example 1

This `span` element contains text content that is automatically **changed** multiple times without user intervention and there is no [instrument][] available to stop, pause, hide or alter the frequency of the automatic changes.
This `span` element contains text content that automatically changes multiple times without user intervention and there is no [instrument][] available to stop, pause, hide or alter the frequency of the automatic changes.

```html
<body onload="startUpdates()">
Expand Down Expand Up @@ -230,7 +226,7 @@ This document does not have any visible text node.

#### Inapplicable Example 2

This document does not have text content that is automatically **changed**.
This document does not have text content that automatically changes.

```html
<p>
Expand All @@ -241,7 +237,7 @@ This document does not have text content that is automatically **changed**.

#### Inapplicable Example 3

This `span` element changes color but not its `innerText` property.
This `span` element changes color but not the content of its [text nodes][] are unchanged.

```html
<body onload="startColorUpdates()">
Expand Down Expand Up @@ -276,7 +272,7 @@ This `span` element changes color but not its `innerText` property.

#### Inapplicable Example 4

This `span` element contains text content that is automatically **changed** but only as a result of the user activating a button on the page.
This `span` element contains text content that automatically changes but only as a result of the user activating a button on the page.

```html
<body>
Expand All @@ -292,24 +288,10 @@ This `span` element contains text content that is automatically **changed** but
</body>
```

#### Inapplicable Example 5

This `span` element with text content that automatically changes multiple times is **alone** in the document.

```html
<body onload="startUpdates()">
<span id="target">1</span>

<script type="text/javascript" src="/test-assets/efbfc7/script.js"></script>
</body>
```
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm a little bit confused where this inapplicable example came from and couldn't find anything in the understanding docs. I would personally fail this example, so I removed it for the moment, re-adding it would mean changing the new applicability.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it worth adding it to the failed examples? - It is a hard call and might be worth asking @Jym77 or @carlosapaduarte for their thoughts?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

SC 2.2.2 states (emphasises mine):

For moving, blinking, scrolling, or auto-updating information, all of the following are true:

  • Moving, blinking, scrolling: For any moving, blinking or scrolling information that (1) starts automatically, (2) lasts more than five seconds, and (3) is presented in parallel with other content, there is a mechanism for the user to pause, stop, or hide it unless the movement, blinking, or scrolling is part of an activity where it is essential; and
  • Auto-updating: For any auto-updating information that (1) starts automatically and (2) is presented in parallel with other content, there is a mechanism for the user to pause, stop, or hide it or to control the frequency of the update unless the auto-updating is part of an activity where it is essential.

This content is not "presented in parallel with other content" and therefore shouldn't fail the SC.


[ancestor]: https://dom.spec.whatwg.org/#concept-tree-ancestor
[activation]: https://html.spec.whatwg.org/#activation
[child]: https://dom.spec.whatwg.org/#concept-tree-child
[children]: https://dom.spec.whatwg.org/#concept-tree-child
[clearly labeled location]: #clearly-labeled-location 'Definition of clearly labeled location'
[content]: https://www.w3.org/TR/WCAG21/#dfn-content
[descendant]: https://dom.spec.whatwg.org/#concept-tree-descendant
[essential]: https://www.w3.org/WAI/WCAG21/Understanding/pause-stop-hide.html#dfn-essential
[flat tree]: https://drafts.csswg.org/css-scoping/#flat-tree 'Definition of flat tree'
[f16]: https://www.w3.org/WAI/WCAG21/Techniques/failures/F16
Expand All @@ -319,6 +301,7 @@ This `span` element with text content that automatically changes multiple times
[instrument]: #instrument-to-achieve-an-objective 'Definition of instrument to achieve an objective'
[sc 2.2.2]: https://www.w3.org/WAI/WCAG21/Understanding/pause-stop-hide
[text node]: https://dom.spec.whatwg.org/#text
[text nodes]: https://dom.spec.whatwg.org/#text
[user interaction]: #user-interaction 'Definition of user interaction'
[visible text content]: #visible-text-content 'Definition of visible text content'
[visible]: #visible 'Definition of visible'
Expand Down