Skip to content
Open
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion src/rules/__tests__/interactive-supports-focus.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,8 @@ makeRuleTester("interactive-supports-focus", rule, {
"<div role='textbox' aria-disabled='true' @click='void 0' />",
"<Foo.Bar @click='void 0' aria-hidden='false' />",
"<Input @click='void 0' type='hidden' />",
`<component role="button" :is="foo ? 'a' : 'button'" />`
`<component role="button" :is="foo ? 'a' : 'button'" />`,
"<div role='textbox' :tabindex='false || 0' :aria-disabled='false' @click='void 0' />",
],
invalid: [
...rule.interactiveRoles.flatMap((role) =>
Expand Down
10 changes: 10 additions & 0 deletions src/utils/getAttributeValue.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,16 @@ function getAttributeValue(node: AST.VAttribute | AST.VDirective) {
return node.value.expression.value;
}

if (node.value.expression.type === 'LogicalExpression') {
const operator = node.value.expression.operator;
// @ts-ignore
const leftSideOfOperation = node.value.expression.left.value;
// @ts-ignore
const rightSideOfOperation = node.value.expression.right.value;

return eval(`${leftSideOfOperation} ${operator} ${rightSideOfOperation}`);
}

// TODO we're effectively using this as just a placeholder to let rules know
// that a value has been passed in for this attribute. We should replace
// this with a stronger API to either explicitly handle all of the different
Expand Down