-
Notifications
You must be signed in to change notification settings - Fork 900
chore: support elements not in tree for get/hasAriaValue #5177
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: develop
Are you sure you want to change the base?
Changes from 2 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,4 +1,4 @@ | ||
| import { nodeLookup } from '../../core/utils'; | ||
| import { nodeLookup, getElementInternals } from '../../core/utils'; | ||
| import standards from '../../standards'; | ||
|
|
||
| /** | ||
|
|
@@ -16,31 +16,37 @@ export default function hasAriaValue(node, attrName) { | |
| throw new TypeError(`Attribute ${attrName} is not an ARIA attribute`); | ||
| } | ||
|
|
||
| const { vNode } = nodeLookup(node); | ||
|
straker marked this conversation as resolved.
|
||
| return ( | ||
| hasAttributeValue(vNode, attrName) || | ||
| hasPropertyValue(vNode, attrStandard) || | ||
| hasInternalValue(vNode, attrStandard) | ||
| hasAttributeValue(node, attrName) || | ||
| hasPropertyValue(node, attrStandard) || | ||
| hasInternalValue(node, attrStandard) | ||
| ); | ||
| } | ||
|
|
||
| function hasAttributeValue(vNode, attrName) { | ||
| return vNode.hasAttr(attrName); | ||
| function hasAttributeValue(node, attrName) { | ||
| const { vNode, domNode } = nodeLookup(node); | ||
| return vNode ? vNode.hasAttr(attrName) : domNode.hasAttribute(attrName); | ||
| } | ||
|
|
||
| function hasPropertyValue(vNode, attrStandard) { | ||
| function hasPropertyValue(node, attrStandard) { | ||
| const { prop } = attrStandard; | ||
| if (prop && vNode.actualNode) { | ||
| const propValue = vNode.actualNode[prop]; | ||
| const { domNode } = nodeLookup(node); | ||
| if (prop && domNode) { | ||
| const propValue = domNode[prop]; | ||
| return propValue !== null && propValue !== undefined; | ||
| } | ||
| return false; | ||
| } | ||
|
|
||
| function hasInternalValue(vNode, attrStandard) { | ||
| function hasInternalValue(node, attrStandard) { | ||
| const { vNode, domNode } = nodeLookup(node); | ||
| const { prop } = attrStandard; | ||
| if (prop && vNode.elementInternals) { | ||
| const internalsValue = vNode.elementInternals[prop]; | ||
| const internals = vNode | ||
| ? vNode.elementInternals | ||
| : getElementInternals(domNode); | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same here, need to put the feature flag gate in. Or maybe put that into getElementInternals directly?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We didn't want to put it directly into |
||
|
|
||
| if (prop && internals) { | ||
| const internalsValue = internals[prop]; | ||
| return internalsValue !== null && internalsValue !== undefined; | ||
| } | ||
| return false; | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.