BUGFIX: template-no-invalid-aria-attributes — accept "undefined" as valid aria-orientation token#29
Closed
BUGFIX: template-no-invalid-aria-attributes — accept "undefined" as valid aria-orientation token#29
Conversation
…d token for aria-orientation Per aria-query 5.3.2, `aria-orientation` has `type: 'token'` with `values: ['vertical', 'undefined', 'horizontal']` — i.e. the literal string "undefined" is an explicit, valid token. Our previous implementation short-circuited on `value === 'undefined'` by returning `Boolean(attrDef.allowundefined)` before the token check. Because `aria-orientation` carries `allowundefined: false` in aria-query, the valid token "undefined" was incorrectly rejected. Fix: before applying the generic `allowundefined` shortcut, check whether the attribute is a `token`/`tokenlist` whose `values` array explicitly includes `'undefined'`. If so, the value is valid regardless of `allowundefined`. Regression tests cover the valid (`undefined`, `horizontal`) and invalid (`sideways`) cases for `aria-orientation`, in both `<template>` and hbs parsers. Reference: audit finding B9 (tests/audit/aria-props/peer-parity.js on audit/phase3/aria-props); PR #28 backlog item F1.
🏎️ Benchmark Comparison
Full mitata output |
Owner
Author
|
Moved upstream to ember-cli#2723. See that PR for ongoing review. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Premise
aria-orientationis defined as{ type: 'token', values: ['vertical', 'undefined', 'horizontal'] }. The literal string\"undefined\"is an explicit, valid token value.attrDef.values.isValidAriaValueshort-circuited onvalue === 'undefined'and returnedBoolean(attrDef.allowundefined)before reaching the token check.aria-querysetsallowundefined: falseonaria-orientation, so the valid literal token\"undefined\"was rejected by the short-circuit.Conclusion
Reorder the checks so that when the attribute is a
token/tokenlistand itsvaluesarray explicitly includes'undefined', we accept it without consultingallowundefined. Theallowundefinedshortcut still applies to every other attribute where\"undefined\"is a general escape hatch (e.g.aria-expanded,aria-pressed), so no existing valid behavior regresses.Changes
lib/rules/template-no-invalid-aria-attributes.js— add the token-list precheck ahead of theallowundefinedshortcut.tests/lib/rules/template-no-invalid-aria-attributes.js— regression tests foraria-orientationin both<template>and hbs parsers:aria-orientation=\"undefined\"aria-orientation=\"horizontal\"aria-orientation=\"sideways\"References
tests/audit/aria-props/peer-parity.json branchaudit/phase3/aria-props(offaudit/a11y-parity). The divergence fixture encodes this bug; once this PR lands, that fixture flips from "divergent" to "aligned".Test plan
npx vitest run tests/lib/rules/template-no-invalid-aria-attributes.js— 74 tests pass.npx prettier --writeon both touched files — no formatting changes.audit/phase3/aria-propsonto master and confirm the B9 divergence fixture passes.