Skip to content

Commit 0810b9e

Browse files
committed
normalize interior whitespace after discussion with accname editors and other browser accessibility engineers
1 parent 93043e9 commit 0810b9e

File tree

2 files changed

+13
-6
lines changed

2 files changed

+13
-6
lines changed

accname/name/comp_text_node.html

+3-3
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,9 @@
1717

1818

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

2525
<h1>text/comment/text nodes, no space</h1>

wai-aria/scripts/aria-utils.js

+10-3
Original file line numberDiff line numberDiff line change
@@ -136,10 +136,17 @@ const AriaUtils = {
136136
let label = el.getAttribute("data-expectedlabel");
137137
let testName = el.getAttribute("data-testname") || label; // data-testname optional if label is unique per test file
138138
promise_test(async t => {
139-
const expectedLabel = el.getAttribute("data-expectedlabel");
139+
let expectedLabel = el.getAttribute("data-expectedlabel");
140140
let computedLabel = await test_driver.get_computed_label(el);
141-
// Todo: Remove whitespace normalization after https://github.com/w3c/accname/issues/192 is addressed. Change prior line back to `const`, too.
142-
computedLabel = computedLabel.trim()
141+
142+
// See: https://github.com/w3c/accname/issues/192 and https://github.com/w3c/accname/issues/208
143+
//
144+
// HTML/JS whitespace matches regular space, formfeed (\f), newline (\n), return (\r), tab (\t), vertical tab (\v),
145+
// non-breaking space (\xA0), and a few more Unicode whitespace characters: \u00A0, \u2028, and \u2029.
146+
const whitespace = /\s+/g;
147+
expectedLabel = expectedLabel.replace(whitespace, ' ').trim();
148+
computedLabel = computedLabel.replace(whitespace, ' ').trim();
149+
143150
assert_equals(computedLabel, expectedLabel, el.outerHTML);
144151
}, `${testName}`);
145152
}

0 commit comments

Comments
 (0)