-
Notifications
You must be signed in to change notification settings - Fork 789
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
fix(frame-focusable-content): don't fail for elements with negative tabindex #3493
Changes from all 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 |
---|---|---|
|
@@ -10,32 +10,45 @@ describe('frame-focusable-content tests', function() { | |
}); | ||
|
||
it('should return true if element has no focusable content', function() { | ||
var vNode = queryFixture('<button id="target"><span>Hello</span></button>'); | ||
var vNode = queryFixture('<div id="target"><span>Hello</span></div>'); | ||
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. Why did you have to change these? 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.
The |
||
assert.isTrue(frameFocusableContent(null, null, vNode)); | ||
}); | ||
|
||
it('should return true if element is empty', function() { | ||
var vNode = queryFixture('<button id="target"></button>'); | ||
var vNode = queryFixture('<div id="target"></div>'); | ||
assert.isTrue(frameFocusableContent(null, null, vNode)); | ||
}); | ||
|
||
it('should return true if element only has text content', function() { | ||
var vNode = queryFixture('<button id="target">Hello</button>'); | ||
var vNode = queryFixture('<div id="target">Hello</div>'); | ||
assert.isTrue(frameFocusableContent(null, null, vNode)); | ||
}); | ||
|
||
it('should return false if element has focusable content', function() { | ||
var vNode = queryFixture( | ||
'<button id="target"><span tabindex="0">Hello</span></button>' | ||
'<div id="target"><span tabindex="0">Hello</span></div>' | ||
); | ||
assert.isFalse(frameFocusableContent(null, null, vNode)); | ||
}); | ||
|
||
it('should return false if element has natively focusable content', function() { | ||
var vNode = queryFixture( | ||
'<button id="target"><a href="foo.html">Hello</a></button>' | ||
'<div id="target"><a href="foo.html">Hello</a></div>' | ||
); | ||
assert.isFalse(frameFocusableContent(null, null, vNode)); | ||
}); | ||
|
||
it('should return true if element is natively focusable but has tabindex=-1', function() { | ||
var vNode = queryFixture( | ||
'<div id="target"><button tabindex="-1">Hello</button></div>' | ||
); | ||
assert.isTrue(frameFocusableContent(null, null, vNode)); | ||
}); | ||
|
||
it('should return false if element is natively focusable but has tabindex=0', function() { | ||
var vNode = queryFixture( | ||
'<div id="target"><button tabindex="0">Hello</button></div>' | ||
); | ||
assert.isFalse(frameFocusableContent(null, null, vNode)); | ||
}); | ||
|
||
}); |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
<!DOCTYPE html> | ||
<html id="focusable"> | ||
<head> | ||
<title>Hello</title> | ||
<meta charset="utf8" /> | ||
<script src="/axe.js"></script> | ||
</head> | ||
<body> | ||
<button tabindex="-1">Click</button> | ||
</body> | ||
</html> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wonder if maybe we should add some option here to say
isFocusable(el, { noNegativeTabindex: true })
?This seem like sort of a common occurance.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree. Though maybe the option could be called
programmatically
? Either way we should do it in a separate pr.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Created #3500