Skip to content
This repository was archived by the owner on Mar 19, 2021. It is now read-only.

Commit 5c61f24

Browse files
rakinachromium-wpt-export-bot
authored andcommitted
Add ARIA role, state and properties to ElementInternals
Adds a way to set default ARIA role, state & properties for custom elements through ElementInternals. These can be overridden with setting the ARIA attributes on the element directly. See whatwg/html#4658 for spec PR. Explainer: https://github.com/alice/aom/blob/gh-pages/explainer.md#per-instance-dynamic-semantics-via-the-elementinternals-object Intent to Implement: https://groups.google.com/a/chromium.org/d/msg/blink-dev/b-cGz9c67pM/0zvBzjhrAAAJ Change-Id: I0caf6bc302445e48f4e0324513105eba3d6303a6 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1709950 Commit-Queue: Rakina Zata Amni <[email protected]> Reviewed-by: Alice Boxhall <[email protected]> Reviewed-by: Kent Tamura <[email protected]> Cr-Commit-Position: refs/heads/master@{#685141}
1 parent 0d4300c commit 5c61f24

File tree

1 file changed

+78
-0
lines changed

1 file changed

+78
-0
lines changed
Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
<!DOCTYPE HTML>
2+
<script src="/resources/testharness.js"></script>
3+
<script src="/resources/testharnessreport.js"></script>
4+
<script>
5+
class TestElement extends HTMLElement {
6+
constructor() {
7+
super();
8+
this._internals = this.attachInternals();
9+
}
10+
11+
get internals() {
12+
return this._internals;
13+
}
14+
15+
set internals(val) {
16+
throw "Can't set internals!";
17+
}
18+
}
19+
customElements.define("test-element", TestElement);
20+
</script>
21+
22+
<test-element id= "testElement"></test-element>
23+
24+
<script>
25+
const element = document.getElementById("testElement");
26+
const properties = [
27+
"role",
28+
"ariaActiveDescendant",
29+
"ariaAtomic",
30+
"ariaAutoComplete",
31+
"ariaBusy",
32+
"ariaChecked",
33+
"ariaColCount",
34+
"ariaColIndex",
35+
"ariaColSpan",
36+
"ariaControls",
37+
"ariaCurrent",
38+
"ariaDescribedBy",
39+
"ariaDetails",
40+
"ariaDisabled",
41+
"ariaErrorMessage",
42+
"ariaExpanded",
43+
"ariaFlowTo",
44+
"ariaHasPopup",
45+
"ariaHidden",
46+
"ariaKeyShortcuts",
47+
"ariaLabel",
48+
"ariaLabelledBy",
49+
"ariaLevel",
50+
"ariaLive",
51+
"ariaModal",
52+
"ariaMultiLine",
53+
"ariaMultiSelectable",
54+
"ariaOrientation",
55+
"ariaOwns",
56+
"ariaPlaceholder",
57+
"ariaPosInSet",
58+
"ariaPressed",
59+
"ariaReadOnly",
60+
"ariaRelevant",
61+
"ariaRequired",
62+
"ariaRoleDescription",
63+
"ariaRowCount",
64+
"ariaRowIndex",
65+
"ariaRowSpan",
66+
"ariaSelected",
67+
"ariaSort",
68+
"ariaValueMax",
69+
"ariaValueMin",
70+
"ariaValueNow",
71+
"ariaValueText"
72+
];
73+
for (const property of properties) {
74+
test(() => {
75+
assert_inherits(element.internals, property);
76+
}, property + " is defined in ElementInternals");
77+
}
78+
</script>

0 commit comments

Comments
 (0)