The Accessibility Tree and WAI-ARIA Semantics vs Custom Elements Lifecycle and Upgrade Reactions
Native elements expose built-in ARIA semantics, whereas autonomous custom elements require ElementInternals to wire roles.
Structured Comparison Matrix
| Dimension | The Accessibility Tree and WAI-ARIA Semantics | Custom Elements Lifecycle and Upgrade Reactions |
|---|---|---|
| Mental Model | Parallel OS-exposed tree derived from the DOM and CSSOM that computes each element's Role, Accessible Name, States, and Properties for assistive technologies. | Build framework-agnostic UI primitives without hydration races—customElements.define() upgrades existing DOM nodes via deterministic lifecycle reaction queues. |
| Maturity & Domain | Baseline · Widely · Security & Accessibility Chrome Full Accessibility Tree · Firefox Full Accessibility Tree · Safari VoiceOver / NSAccessibility | Baseline · Widely · DOM & Events Chrome 67+ · Firefox 63+ · Safari 10.1+ |
| Prerequisites | ||
| When Not to Use | When not to use ARIA: Whenever a native HTML element (<button>, <a href>, <input>, <dialog>) already carries the required role and keyboard behavior, omit redundant role attributes; for Custom Elements, expose roles via ElementInternals instead of mutating host aria-* attributes. | When not to use Custom Elements: Avoid wrapping every leaf UI primitive in a custom element if your app already compiles single-framework SSR templates, use them for cross-framework widgets or design-system leaves. |
Engine Mechanics & Trade-Offs
The browser builds a parallel Accessibility Tree from semantic HTML and ARIA attributes, filtering display:none/aria-hidden nodes and computing Accessible Names for OS screen readers.
Key Pitfalls: First Rule of ARIA violation: Replacing <button> with <div role="button"> drops keyboard activation, form submission, and disabled semantics for zero gain. aria-hidden="true" on focusable elements: Leaves the button reachable via Tab while hiding its announcement from screen readers ("ghost focus"); use the inert attri
Custom Elements upgrade DOM nodes via CustomElementRegistry, queuing constructor, connectedCallback, and attributeChangedCallback reactions deterministically.
Key Pitfalls: DOM Mutations in constructor(): Calling this.setAttribute() in constructor() throws NotSupportedError during HTML parsing. Safari Built-in Rejection: Extending <button is="my-btn"> (extends: 'button') is unsupported in Safari; always use autonomous tags.