Skip to content

Commit

Permalink
normalize interior whitespace after discussion with accname editors a…
Browse files Browse the repository at this point in the history
…nd other browser accessibility engineers
  • Loading branch information
cookiecrook committed Oct 11, 2023
1 parent 2209875 commit a324df1
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 6 deletions.
6 changes: 3 additions & 3 deletions accname/name/comp_text_node.html
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@


<h1>text/element/text nodes, no space</h1>
<button class="ex" data-expectedlabel="buttonlabel" data-testname="button with text/comment/text nodes, no space">button<span></span>label</button>
<h3 class="ex" data-expectedlabel="headinglabel" data-testname="heading with text/comment/text nodes, no space">heading<span></span>label</h3>
<a href="#" class="ex" data-expectedlabel="linklabel" data-testname="link with text/comment/text nodes, no space">link<span></span>label</a>
<button class="ex" data-expectedlabel="buttonlabel" data-testname="button with text/element/text nodes, no space">button<span></span>label</button>
<h3 class="ex" data-expectedlabel="headinglabel" data-testname="heading with text/element/text nodes, no space">heading<span></span>label</h3>
<a href="#" class="ex" data-expectedlabel="linklabel" data-testname="link with text/element/text nodes, no space">link<span></span>label</a>
<br>

<h1>text/comment/text nodes, no space</h1>
Expand Down
13 changes: 10 additions & 3 deletions wai-aria/scripts/aria-utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -136,10 +136,17 @@ const AriaUtils = {
let label = el.getAttribute("data-expectedlabel");
let testName = el.getAttribute("data-testname") || label; // data-testname optional if label is unique per test file
promise_test(async t => {
const expectedLabel = el.getAttribute("data-expectedlabel");
let expectedLabel = el.getAttribute("data-expectedlabel");
let computedLabel = await test_driver.get_computed_label(el);
// Todo: Remove whitespace normalization after https://github.com/w3c/accname/issues/192 is addressed. Change prior line back to `const`, too.
computedLabel = computedLabel.trim()

// See: https://github.com/w3c/accname/issues/192 and https://github.com/w3c/accname/issues/208
//
// HTML/JS whitespace matches regular space, formfeed (\f), newline (\n), return (\r), tab (\t), vertical tab (\v),
// non-breaking space (\xA0), and a few more Unicode whitespace characters: \u00A0, \u2028, and \u2029.
const whitespace = /\s+/g;
expectedLabel = expectedLabel.replace(whitespace, ' ').trim();
computedLabel = computedLabel.replace(whitespace, ' ').trim();

assert_equals(computedLabel, expectedLabel, el.outerHTML);
}, `${testName}`);
}
Expand Down

0 comments on commit a324df1

Please sign in to comment.