Skip to content

added Shiv check so show/hide work with Modernizr#716

Closed
BigBlueHat wants to merge 1 commit intojquery:masterfrom
BigBlueHat:Modernizr_Shiv_defaultDisplay_handling
Closed

added Shiv check so show/hide work with Modernizr#716
BigBlueHat wants to merge 1 commit intojquery:masterfrom
BigBlueHat:Modernizr_Shiv_defaultDisplay_handling

Conversation

@BigBlueHat
Copy link

Patch for http://bugs.jquery.com/ticket/11520

.show() will now set article and other HTML5 tags to their "shived" value.

I realize this relates to an external/3rd-party library, but there seems to already be some precedence for "playing nice" along side Modernizr.

Not sure what the "policy" is for this sort of thing, but I'm happy to help come at this problem differently if a direct patch to jQuery is not the best route. Also, if the code formatting, variable names, or whatever are "off" just let me know. Happy to cleanup/fix/patch/whatever.

Thanks.

@rwaldron
Copy link
Member

I'm not sure what precedent of "playing nice" you speak of, but jQuery shouldn't be making biased concessions - if we start with this, then we have to accept every single request that follows.

@timmywil
Copy link
Member

Too much code for this case.

@timmywil timmywil closed this Mar 26, 2012
@BigBlueHat
Copy link
Author

This issue (among others) reference html5shiv compatibility tweaks:
http://bugs.jquery.com/ticket/11055

I agree this may be "too much code" but not having it means that .show() must be avoided in shived code that uses jQuery and that .show() will have unexpected consequences.

Is there a way I can patch this that's more acceptable?

Just trying to help, here. :)

@rwaldron
Copy link
Member

.show() must be avoided in shived code that uses jQuery

No, instead of overriding the default display of a node, you should be using a class

@BigBlueHat
Copy link
Author

@mikecrittenden right. Good catch. :/

@rwldrn so the short answer is, "don't use .show() on HTML5 tags?"

@rwaldron
Copy link
Member

No, that's not what I said at all.

This:

/* my app hides them by default */
article {display:none}​

Is a broken approach and should be avoided in all cases

@mikesherov
Copy link
Member

@BigBlueHat, if you inspect the effects.js code carefully, you'll notice that jQuery tries to determine the correct "show" style style before .show().

It does this by first checking to see if it was originally shown, and therefore should have some .data stored for what the correct show value is.
Next, it tries to get the current style, which in this case is "none". So no good there.
It continues... next it tries to create a node of that element type on the current page. If you didn't have article {display:none}​, jQuery would be able to determine the default modernized style. However, the default style of that element type is none!
Now, jQuery takes desparate measures... it creates a hidden iframe, and than appends a node of that element type to the iframe to finally determine the correct default show value. In this case, the iframe is not modernized, and therefore, oldIE will give the default type it does for unknown elements: block.

The solution, as @rwldrn says, is to remove the article {display:none}​ so that jQuery can determine the correct show value for that element type without creating a new iframe, thus preserving the modernized default show value.

@mikesherov
Copy link
Member

Actually, @BigBlueHat is right, this is a reduced test case in oldIE: http://jsfiddle.net/mLLL5/2/

@rwaldron
Copy link
Member

It was always assumed that by using the html5shiv, that usercode would also include the nec. base stylesheet for html5 elements.

Also, Mike, you're using the known broken html5shiv. Try this in IE8: http://jsfiddle.net/rwaldron/mLLL5/5/

@rwaldron
Copy link
Member

@mikesherov
Copy link
Member

Yeah, wasn't aware that jsfiddle was using the broken one. My bad.

@lock lock bot locked as resolved and limited conversation to collaborators Jan 21, 2019
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