-
Notifications
You must be signed in to change notification settings - Fork 811
[fixed] element with display 'contents' is visible and is tabbable. #906
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
Changes from 1 commit
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,8 +10,17 @@ | |
| * http://api.jqueryui.com/category/ui-core/ | ||
| */ | ||
|
|
||
| const DISPLAY_NONE = "none"; | ||
| cosnt DISPLAY_CONTENTS = "contents"; | ||
|
|
||
| const tabbableNode = /input|select|textarea|button|object/; | ||
|
|
||
| function hasElementOverflow(element, style) { | ||
| return style.getPropertyValue("overflow") !== "visible" || | ||
| // if 'overflow: visible' set, check if there is actually any overflow | ||
| (element.scrollWidth <= 0 && element.scrollHeight <= 0); | ||
| } | ||
|
|
||
|
Comment on lines
+18
to
+23
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. Isn't the naming backwards? If the function returns true, the element does not overflow (either because its content is clipped or its content is actually 0x0 in size) |
||
| function hidesContents(element) { | ||
| const zeroSize = element.offsetWidth <= 0 && element.offsetHeight <= 0; | ||
|
|
||
|
|
@@ -21,11 +30,10 @@ function hidesContents(element) { | |
| try { | ||
| // Otherwise we need to check some styles | ||
| const style = window.getComputedStyle(element); | ||
| return zeroSize | ||
| ? style.getPropertyValue("overflow") !== "visible" || | ||
| // if 'overflow: visible' set, check if there is actually any overflow | ||
| (element.scrollWidth <= 0 && element.scrollHeight <= 0) | ||
| : style.getPropertyValue("display") == "none"; | ||
| const displayValue = style.getPropertyValue("display"); | ||
| return displayValue !== DISPLAY_CONTENTS && (zeroSize | ||
| ? hasElementOverflow(element, style) | ||
| : displayValue === DISPLAY_NONE); | ||
|
Comment on lines
+33
to
+36
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. Personally, I'd go with return zeroSize
? displayValue !== DISPLAY_CONTENTS && hasElementOverflow(element, style)
: displayValue === DISPLAY_NONE;but that's mostly a matter of taste. Either way works. |
||
| } catch (exception) { | ||
| // eslint-disable-next-line no-console | ||
| console.warn("Failed to inspect element style"); | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.