Skip to content
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

Rule update: Name from content included in accessible name (2ee8b8) #452

Closed

Conversation

annethyme
Copy link
Collaborator

@annethyme annethyme commented Mar 20, 2019

This pull request has been split out from #430.

Closes issue:

How to Review And Approve

  • Go to the “Files changed” tab
  • Here you will have the option to leave comments on different lines.
  • Once the review is completed, find the “Review changes” button in the top right, select “Approve” (if you are really confident in the rule) or "Request changes" and click “Submit review”.

@annethyme annethyme added Rule Update Use this label for an existing rule that is being updated Rule Use this label for a new rule that does not exist already labels Mar 20, 2019
@annethyme annethyme self-assigned this Mar 20, 2019
annethyme pushed a commit that referenced this pull request Mar 20, 2019
annethyme pushed a commit that referenced this pull request Mar 20, 2019
Splitting this one out into #452
annethyme pushed a commit that referenced this pull request Mar 20, 2019
Splitting this one out into #452
annethyme pushed a commit that referenced this pull request Mar 20, 2019
Splitting this one out into #452
@annethyme
Copy link
Collaborator Author

Discussion on "character" definition taken from the PR (#430) that this one has been split out from:
#430 (comment)

@JKODU:

character seems like a generic definition that we can refer to elsewhere? Perhaps - https://developer.mozilla.org/en-US/docs/Glossary/Character

I see you drawing some distinction away from grapheme, then may be this should not be called character?

@kasperisager:

The issue is that computers don't really deal in graphemes. A language such as JavaScript, for example, represents strings of "characters" as sequences of UTF-16 code points, while other languages, such as C and Go, represent strings of "characters" as sequences of arbitrary bytes. The term "character" therefore has lots of different meanings in different contexts.

@annethyme annethyme changed the title Update rule: Label and name from content mismatch Rule update: Label and name from content mismatch Mar 20, 2019
@annethyme annethyme requested review from kasperisager and removed request for kasperisager March 22, 2019 15:04
Copy link
Collaborator

@ShadowBB ShadowBB left a comment

Choose a reason for hiding this comment

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

Splendid work.

The first 2 examples should be inapplicable examples. Apart from that I will approve this.

@Jym77
Copy link
Collaborator

Jym77 commented Oct 17, 2019

Another fun example, related to #976:

<div role="link" aria-label="next 
   
   page">Next page</div>

As far as I understand accessible name computation, the extra spaces and newline should be removed from the accessible name when it is flattened and thus this should pass the rule even though the name from content is not included in the aria-label.
More elaborate cases with aria-labelledby reading several other elements can also be achieved.

@jeeyyy
Copy link
Collaborator

jeeyyy commented Nov 4, 2019

Reviewers, I have updated this rule. Please review again. I am aware of the failing test status check, but this should not stop from reviewing.

Copy link
Member

@carlosapaduarte carlosapaduarte left a comment

Choose a reason for hiding this comment

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

editorial changes needed


## Expectation

The complete [visible text content](#visible-text-content) of the target element either matches or is contained within its [accessible name][].
After removing all [punctuation](#punctuation) from both the [visible](#visible) [descendant text content](https://dom.spec.whatwg.org/#concept-descendant-text-content) and the [accessible name](#accessible-name), the [visible](#visible) [descendant text content](https://dom.spec.whatwg.org/#concept-descendant-text-content) of the target element is [included](#included-characters) in its entirety within the [accessible name](#accessible-name) of the element, except for parts of the [visible](#visible) [descendant text content](https://dom.spec.whatwg.org/#concept-descendant-text-content) that do not express anything in [human language](https://www.w3.org/TR/WCAG21/#dfn-human-language-s) and therefore does not live up to the [WCAG definition of text](https://www.w3.org/TR/WCAG21/#dfn-text).
Copy link
Collaborator

Choose a reason for hiding this comment

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

How do you compute "visible descendant text content"?

<button>
  <span id="foo">foo</span>
  <span id="space"> </span>
  <span id="hidden" style="display: none">foobar</span>
  <span id="bar">bar baz</span>
  <span id="off-screen" style="position: absolute; left: -999px;">Hello</span>
</button>

What is the "visible descendant text content" of this button?
For this rule purpose, the intend is probably that it should be foo bar baz but

  • Why should we include the invisible span id="space" but exclude the invisible span id="hidden" or span id="off-screen"?
  • Even within the span id="bar", why do we include the invisible space character?

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 talking with @kasperisager about this (and my related issues with the definition of visible, see #977).

One way out of it would be to have a definition of "rendered node" (or similar) in the line of:

a node is rendered if removing it from the DOM tree changes the rendered content.

That way, the span id="space" above would contain a rendered text node (with text content " "). But the span id="hidden" and span id="off-screen" would not.

Similarly, an example like #977 (comment)

<p style="background: #white; text-shadow: black 0 0 0px">
  <span style="color: rgba(0,0,0,0); ">Some text in a human language</span>
</p>

where the text is technically not visible (only the shadow is) would still have a rendered text node.


The drawbacks with that are:

  • Some nodes like above can be invisible but still have rendered text nodes descendants. That's a bit weird but fairly OK (and anyway a consequence of whitespace being invisible).
  • If the shadow above is made more blurry, it gets harder and harder to read its content, to the point that it gets hard to argue that the text content should be used (e.g. to consider it as a WCAG label).
  • Something like <span style="background: red; color: red;">Foo</span> has a rendered text node because the span stretch for the same width as the text.

(because of these tricky cases and the weird interaction with visible, the definition of rendered can probably use examples…)

All these are pretty edge cases and they can be handled by an assumption in the line of

This rule assumes that no text node is both rendered and not visible.

(likely needs an explanatory note with examples like spaces)
(essentially, "don't use spaces for layout!")


With an assumption like that, this rule can use "visible descendant text nodes" or something similar to grab what is needed.

A character is a [code point](http://unicode.org/glossary/#code_point), specifically an integer, that a computer uses for representing a value within the Unicode system.
As such, multiple characters may represent the same glyph and multiple glyphs may represent the same grapheme.

## Examples
Copy link
Collaborator

Choose a reason for hiding this comment

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

Still needs to be done.

Copy link
Member

@carlosapaduarte carlosapaduarte left a comment

Choose a reason for hiding this comment

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

Just a couple of editorial. But I think the point raised by @Jym77 needs to be addressed also.

Co-Authored-By: carlosapaduarte <carlosapaduarte@gmail.com>
@kasperisager kasperisager removed their request for review April 24, 2020 09:54
@WilcoFiers
Copy link
Member

Closing due to inactivity.

@WilcoFiers WilcoFiers closed this May 15, 2020
@jeeyyy jeeyyy deleted the update-rule-SC2-5-3-label-content-name-mismatch branch July 3, 2020 16:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Rule Update Use this label for an existing rule that is being updated
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet