Skip to content

Focusable: Fix handling of visibility: inherit #1605

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

Closed

Conversation

scottgonzalez
Copy link
Member

Ref #14596
Ref gh-1583

@jzaefferer
Copy link
Member

Tests?

@jzaefferer
Copy link
Member

Nevermind, saw your comment about IE8. Looks good to me.

@scottgonzalez
Copy link
Member Author

I can add a test that explicitly assigned visibility: inherit which would cause all browsers to hit this code path.

@jzaefferer
Copy link
Member

That seems useful.

};

function visible( element ) {
var visibility = element.css( "visibility" );
while ( visibility === "inherit" ) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this also check for element.length !== 0 to avoid a possible infinite loop?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is no possible infinite loop here. If the element doesn't exist, it can't have a visibility of "inherit".

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Of course. 👍

@scottgonzalez
Copy link
Member Author

Tests added. It turns out that even with these tests, only IE 8 will hit the new code path. All other browsers resolve inherit to either hidden or visible when getting the computed value (which makes sense). As such, I've marked the visible() method as supporting IE 8, but not the tests. The test cases are still valid, and if the implementation were to ever change to checking element.style instead of the computed style, the tests would catch the failure (unless the tree walking logic still existed).

@jzaefferer
Copy link
Member

Looks good. Somewhat related: medialize/ally.js#41

@scottgonzalez scottgonzalez deleted the focusable-visibility-inherit branch February 9, 2016 18:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

4 participants