Landing pull request 490. 1.7 HTML5 Support for innerHTML, clone & style. Fixes #6485.

More Details:
 - https://github.com/jquery/jquery/pull/490
 - http://bugs.jquery.com/ticket/6485
This commit is contained in:
Rick Waldron
2011-09-19 16:42:36 -04:00
committed by timmywil
parent bba3d610c7
commit 9ecdb2472b
4 changed files with 65 additions and 2 deletions

View File

@@ -20,7 +20,23 @@ var rinlinejQuery = / jQuery\d+="(?:\d+|null)"/g,
col: [ 2, "<table><tbody></tbody><colgroup>", "</colgroup></table>" ],
area: [ 1, "<map>", "</map>" ],
_default: [ 0, "", "" ]
};
},
safeFragment = (function() {
var nodeNames = (
"abbr article aside audio canvas datalist details figcaption figure footer " +
"header hgroup mark meter nav output progress section summary time video"
).split( " " ),
safeFrag = document.createDocumentFragment();
if ( safeFrag.createElement ) {
while ( nodeNames.length ) {
safeFrag.createElement(
nodeNames.pop()
);
}
}
return safeFrag;
})();
wrapMap.optgroup = wrapMap.option;
wrapMap.tbody = wrapMap.tfoot = wrapMap.colgroup = wrapMap.caption = wrapMap.thead;
@@ -625,6 +641,9 @@ jQuery.extend({
depth = wrap[0],
div = context.createElement("div");
// Append wrapper element to unknown element safe doc fragment
safeFragment.appendChild( div );
// Go to html and back, then peel off extra wrappers
div.innerHTML = wrap[1] + elem + wrap[2];

View File

@@ -24,7 +24,7 @@ jQuery.support = (function() {
// Preliminary tests
div.setAttribute("className", "t");
div.innerHTML = " <link/><table></table><a href='/a' style='top:1px;float:left;opacity:.55;'>a</a><input type='checkbox'/>";
div.innerHTML = " <link/><table></table><a href='/a' style='top:1px;float:left;opacity:.55;'>a</a><input type='checkbox'/><nav></nav>";
all = div.getElementsByTagName( "*" );
@@ -69,6 +69,9 @@ jQuery.support = (function() {
// (IE uses styleFloat instead of cssFloat)
cssFloat: !!a.style.cssFloat,
// Make sure unknown elements (like HTML5 elems) are handled appropriately
unknownElems: !!div.getElementsByTagName( "nav" ).length,
// Make sure that if no value is specified for a checkbox
// that it defaults to "on".
// (WebKit defaults to "" instead)