Skip to content

Conversation

@gibson042
Copy link
Member

Fixes gh-2654
Fixes gh-2308
Ref 86419b1

   raw     gz Compared to master @ fb9472c7fbf9979f48ef49aff76903ac130d0959    
  +954   +271 dist/jquery.js                                                   
  +310    +99 dist/jquery.min.js

Copy link
Member Author

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.

Copy link
Member

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

Copy link
Member Author

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.

Copy link
Member

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:

  1. When body/html is hidden
  2. 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.

@markelog
Copy link
Member

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.
Not a blocker though, but i think we shouldn't put it under the bed

Copy link
Member

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

Copy link
Member Author

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.

@markelog
Copy link
Member

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
Copy link
Member

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

Copy link
Member

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

Copy link
Member Author

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.

@gibson042
Copy link
Member Author

@markelog Updated.

@timmywil
Copy link
Member

LGTM

@timmywil
Copy link
Member

I'd like to land this today if possible.

@gibson042
Copy link
Member Author

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.
Not a blocker though, but i think we shouldn't put it under the bed

I intentionally excluded elements like <style> and <script> that are display: none by default, but tried to include everything else. Did I miss something?

@markelog
Copy link
Member

@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 jQuery.defaultDisplay being added only in 3.1 it is okay with me

Copy link
Member

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?

Copy link
Member Author

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 timmywil closed this in dba93f7 Jan 13, 2016
@markelog
Copy link
Member

@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 show()/hide() applied while they were detached, for reference -
https://bugs.jquery.com/ticket/10416
https://bugs.jquery.com/ticket/10006

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.

@markelog
Copy link
Member

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 defaultDisplay property wasn't set

@timmywil
Copy link
Member

@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.

@markelog
Copy link
Member

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.

We were checking display regardless before. That's the reason for the speed boost.

I don't understand this statement. And you didn't answer to my suggestion in #2810 (comment)

@timmywil
Copy link
Member

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).

@timmywil
Copy link
Member

I really don't get it

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.

@timmywil
Copy link
Member

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?

@timmywil
Copy link
Member

@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.

@timmywil
Copy link
Member

@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.

@gibson042
Copy link
Member Author

Confirmed the failing tests. I'll take a look later today.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Development

Successfully merging this pull request may close these issues.

5 participants