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
Fixes #11528 - IE <= 8 can't serialize html5 elements sometimes #718
Conversation
if ( !jQuery.support.htmlSerialize ) { | ||
wrapMap._default = [ 1, "div<div>", "</div>" ]; | ||
wrapMap._default = [ 1, "X<div>", "</div>" ]; |
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.
typo 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.
No, the "div" text is just a shim, it can be anything. I use "X" to shave off the two characters. It would ideally be something like "shim" if every byte of jquery didn't translate into petabytes of internet traffic. Personally I found it more confusing as "div" than as "X".
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.
You could try changing X
to c
to check if the GZIP algo will better optimize the c<d
part of the string - which is used several times throughout the minified jQuery 1.7.2 source.
</bikeshed>
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.
My tests show that switching it from "div" to "X." shaves off one gzipped byte. I tried "c" and even ">" and got the same number of bytes as "X".
And actually I appreciate the reminder to think about gzip results. Byte count, compressed or uncompressed, isn't much of a priority in my day job, so I often overlook it. The real reason I wanted to replace "div" is that it makes it look somehow magical, like it needs to be that particular text, when in fact it can be any character at all.
(edit - trying to make it so that the divs don't gobble up the text)
Looks good in the IEs (6,7,8) |
+1, I use |
+1 on the use of something other than |
Landed in 1.8pre, 4cd57d7. Thanks! |
Basically this patch just excludes innerHTML from being used in the .html() function if an html5 tag is being inserted and the ie serialization bug is present. This forces it to use the append method, which should properly apply the html5shiv code.