-
Notifications
You must be signed in to change notification settings - Fork 20.5k
CSS: Restore cascade-override behavior in .show #2810
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
Conversation
src/css/showHide.js
Outdated
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.
If the "force visibility" behavior is here to stay, we should consider a public jQuery.defaultDisplay( element ) interface so this function doesn't go the way of its predecessor.
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.
That's because of the if none the block thing? So if there would be a case, when, say inline element would be added to the hidden body, user could re-define it.
I like it, i would even consider it to be a blocker for the release
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.
Nah, such an extension could easily be 3.1.0.
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.
To to be clear, without that hook we loosing two use-cases:
- When
body/htmlis hidden - When all specific node-types are hidden, like
li {display: none}First might exist in, at least, worlds like SPA or iframes, there is probably more weird use-cases out there.
As of all specific elements being hidden, there might be some legit cases for very simple pages.
I think it would be good to provide some workarounds for it.
|
How this correlates with your table there - https://gist.github.com/scottgonzalez/5aadcd7e37cccced1239 In the meeting we discuss the possibility of documenting it. I'd say we need to tests for every value of it. |
src/css/showHide.js
Outdated
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.
So setDefaultDisplay is a getter? I would suggest to write it like
values[ index ] = getDefaultDisplay( elem );And incapsulate everything else
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 suppose the clarity is worth 4 bytes. Updating.
|
With your if ( display === "none" ) {
display = "block";
}you drained all fun from it :-), but i guess we can check out users reaction of the beta release. |
test/unit/css.js
Outdated
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.
Yeah, please make it more simpler, pretty convoluted. I'd say tests is not the place where we need to be clever
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.
Not sure what these lines supposed to do - className and style are always empty here
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.
Copypasta. They are the same in each test of this family.
|
@markelog Updated. |
|
LGTM |
|
I'd like to land this today if possible. |
I intentionally excluded elements like |
|
@gibson042 Oh, yeah, this table includes only non-animated elements, can't find the full one though, which includes animated elements too. I meant those more then others. @timmywil if everyone okay with |
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.
So this could became jQuery.defaultDisplay right?
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.
Correct. And notably, the input is an element rather than a tag name—it allows for context-sensitivity, but doesn't incur any significant extra cost for a simple cached global treatment like ours.
|
@timmywil aside from the benchmark being incorrect (after the first run, you hide already hidden elements), the reason for speed bump, is that we are dropping the third case - all re-attached elements will have incorrect display if Now those are legit, no question, if you feel strongly about dropping them, i think we should explicitly notice all the no longer supported use-cases, why we are dropping them and provide documentation for it too. Gotta say, this is reason why should have brought back previous tests, without claiming them "bad", since we didn't know what we are trading for performance, they are regressions by definition. |
|
fixed http://jsperf.com/old-vs-new-show-hide/2, but this also doesn't reflect real use-case when perf questions were started, "wikipedia" one, when elements changed their display on the first run, when |
|
@markelog It's not invalid. You missed the point. It wasn't so much testing what happens when hiding elements, it was testing the codepath for hiding, which is faster. It doesn't matter whether they were already hidden or not. We were checking display regardless before. That's the reason for the speed boost. |
|
I don't understand how it could be correct, if you test the code path that would never be taken in real application. It doesn't matter what code path would be taken and how fast it is for the bogus use-case.
I don't understand this statement. And you didn't answer to my suggestion in #2810 (comment) |
|
The use case is not that relevant. It was testing the hide path in showHide accurately. And I can't view the tickets you linked (502 Bad Gateway). |
I really don't get it, how it could be "not relevant" if that code path would never be taken? How in the world does it not matter?
Oh, come on - |
It is hitting the codepath whether the elements are hidden or not. http://jsperf.com/old-vs-new-show-hide/3 Re-show the elements in teardown instead and you can see that you get the same results. As for the links, I always forget about webcache. |
|
Ok, for the cases you mentioned, I think I agree that they seem rare enough. Let's discuss in chat, either in -dev or in a meeting, but do you agree they could be addressed after the beta? |
|
@markelog and I talked this over in irc. We probably would have been commenting here for a while. We agreed that hide is faster and while the perf demonstrates that, what I didn't realize was that show might be faster for the reasons @markelog mentioned. We're figuring out what to do about the other tickets in -dev. |
|
@gibson042 There's an issue with disconnected elements in FF. It looks like it's respecting the cascade even when disconnected. For instance, this test fails because FF gets a computed display of "none" instead of empty string, gets a proper default display of block and applies it. |
|
Confirmed the failing tests. I'll take a look later today. |

Fixes gh-2654
Fixes gh-2308
Ref 86419b1