Commit fd2af63b authored by Oleg's avatar Oleg

Remove createSafeFragment helper

parent 861a45b8
function createSafeFragment( document ) { var rleadingWhitespace = /^\s+/,
var list = nodeNames.split( "|" ),
safeFrag = document.createDocumentFragment();
if ( safeFrag.createElement ) {
while ( list.length ) {
safeFrag.createElement(
list.pop()
);
}
}
return safeFrag;
}
var nodeNames = "abbr|article|aside|audio|bdi|canvas|data|datalist|details|figcaption|figure|footer|" +
"header|hgroup|mark|meter|nav|output|progress|section|summary|time|video",
rinlinejQuery = / jQuery\d+="(?:null|\d+)"/g,
rnoshimcache = new RegExp("<(?:" + nodeNames + ")[\\s/>]", "i"),
rleadingWhitespace = /^\s+/,
rxhtmlTag = /<(?!area|br|col|embed|hr|img|input|link|meta|param)(([\w:]+)[^>]*)\/>/gi, rxhtmlTag = /<(?!area|br|col|embed|hr|img|input|link|meta|param)(([\w:]+)[^>]*)\/>/gi,
rtagName = /<([\w:]+)/, rtagName = /<([\w:]+)/,
rtbody = /<tbody/i, rtbody = /<tbody/i,
...@@ -37,13 +19,8 @@ var nodeNames = "abbr|article|aside|audio|bdi|canvas|data|datalist|details|figca ...@@ -37,13 +19,8 @@ var nodeNames = "abbr|article|aside|audio|bdi|canvas|data|datalist|details|figca
tr: [ 2, "<table><tbody>" ], tr: [ 2, "<table><tbody>" ],
col: [ 2, "<table><tbody></tbody><colgroup>", "</table>" ], col: [ 2, "<table><tbody></tbody><colgroup>", "</table>" ],
td: [ 3, "<table><tbody><tr>" ], td: [ 3, "<table><tbody><tr>" ],
_default: [ 0, "" ]
// IE6-8 can't serialize link, script, style, or any html5 (NoScope) tags, };
// unless wrapped in a div with non-breaking characters in front of it.
_default: jQuery.support.htmlSerialize ? [ 0, "" ] : [ 1, "X<div>" ]
},
safeFragment = createSafeFragment( document ),
fragmentDiv = safeFragment.appendChild( document.createElement("div") );
wrapMap.optgroup = wrapMap.option; wrapMap.optgroup = wrapMap.option;
wrapMap.tbody = wrapMap.tfoot = wrapMap.colgroup = wrapMap.caption = wrapMap.thead; wrapMap.tbody = wrapMap.tfoot = wrapMap.colgroup = wrapMap.caption = wrapMap.thead;
...@@ -213,14 +190,11 @@ jQuery.fn.extend({ ...@@ -213,14 +190,11 @@ jQuery.fn.extend({
l = this.length; l = this.length;
if ( value === undefined ) { if ( value === undefined ) {
return elem.nodeType === 1 ? return elem.nodeType === 1 ? elem.innerHTML: undefined;
elem.innerHTML.replace( rinlinejQuery, "" ) :
undefined;
} }
// See if we can take a shortcut and just use innerHTML // See if we can take a shortcut and just use innerHTML
if ( typeof value === "string" && !rnoInnerhtml.test( value ) && if ( typeof value === "string" && !rnoInnerhtml.test( value ) &&
( jQuery.support.htmlSerialize || !rnoshimcache.test( value ) ) &&
( jQuery.support.leadingWhitespace || !rleadingWhitespace.test( value ) ) && ( jQuery.support.leadingWhitespace || !rleadingWhitespace.test( value ) ) &&
!wrapMap[ ( rtagName.exec( value ) || ["", ""] )[1].toLowerCase() ] ) { !wrapMap[ ( rtagName.exec( value ) || ["", ""] )[1].toLowerCase() ] ) {
...@@ -559,18 +533,11 @@ function fixDefaultChecked( elem ) { ...@@ -559,18 +533,11 @@ function fixDefaultChecked( elem ) {
jQuery.extend({ jQuery.extend({
clone: function( elem, dataAndEvents, deepDataAndEvents ) { clone: function( elem, dataAndEvents, deepDataAndEvents ) {
var destElements, srcElements, node, i, clone, var destElements, srcElements, node, i,
inPage = jQuery.contains( elem.ownerDocument, elem ); inPage = jQuery.contains( elem.ownerDocument, elem ),
if ( jQuery.support.html5Clone || jQuery.isXMLDoc(elem) || !rnoshimcache.test( "<" + elem.nodeName + ">" ) ) {
clone = elem.cloneNode( true ); clone = elem.cloneNode( true );
// IE<=8 does not properly clone detached, unknown element nodes // IE<=8 does not properly clone detached, unknown element nodes
} else {
fragmentDiv.innerHTML = elem.outerHTML;
fragmentDiv.removeChild( clone = fragmentDiv.firstChild );
}
if ( (!jQuery.support.noCloneEvent || !jQuery.support.noCloneChecked) && if ( (!jQuery.support.noCloneEvent || !jQuery.support.noCloneChecked) &&
(elem.nodeType === 1 || elem.nodeType === 11) && !jQuery.isXMLDoc(elem) ) { (elem.nodeType === 1 || elem.nodeType === 11) && !jQuery.isXMLDoc(elem) ) {
...@@ -616,7 +583,7 @@ jQuery.extend({ ...@@ -616,7 +583,7 @@ jQuery.extend({
clean: function( elems, context, fragment, scripts, selection ) { clean: function( elems, context, fragment, scripts, selection ) {
var elem, i, j, tmp, tag, wrap, tbody, var elem, i, j, tmp, tag, wrap, tbody,
ret = [], ret = [],
safe = context === document && safeFragment; container = context === document && fragment;
// Ensure that context is a document // Ensure that context is a document
if ( !context || typeof context.createDocumentFragment === "undefined" ) { if ( !context || typeof context.createDocumentFragment === "undefined" ) {
...@@ -636,8 +603,8 @@ jQuery.extend({ ...@@ -636,8 +603,8 @@ jQuery.extend({
// Convert html into DOM nodes // Convert html into DOM nodes
} else { } else {
// Ensure a safe container // Ensure a safe container
safe = safe || createSafeFragment( context ); container = container || context.createDocumentFragment();
tmp = tmp || safe.appendChild( context.createElement("div") ); tmp = tmp || container.appendChild( context.createElement("div") );
// Deserialize a standard representation // Deserialize a standard representation
tag = ( rtagName.exec( elem ) || ["", ""] )[1].toLowerCase(); tag = ( rtagName.exec( elem ) || ["", ""] )[1].toLowerCase();
...@@ -686,14 +653,14 @@ jQuery.extend({ ...@@ -686,14 +653,14 @@ jQuery.extend({
} }
// Remember the top-level container for proper cleanup // Remember the top-level container for proper cleanup
tmp = safe.lastChild; tmp = container.lastChild;
} }
} }
} }
// Fix #11356: Clear elements from safeFragment // Fix #11356: Clear elements from fragment
if ( tmp ) { if ( tmp ) {
safe.removeChild( tmp ); container.removeChild( tmp );
} }
// Reset defaultChecked for any radios and checkboxes // Reset defaultChecked for any radios and checkboxes
...@@ -704,7 +671,7 @@ jQuery.extend({ ...@@ -704,7 +671,7 @@ jQuery.extend({
if ( fragment ) { if ( fragment ) {
for ( i = 0; (elem = ret[i]) != null; i++ ) { for ( i = 0; (elem = ret[i]) != null; i++ ) {
safe = jQuery.contains( elem.ownerDocument, elem ); container = jQuery.contains( elem.ownerDocument, elem );
// Append to fragment // Append to fragment
// #4087 - If origin and destination elements are the same, and this is // #4087 - If origin and destination elements are the same, and this is
...@@ -715,7 +682,7 @@ jQuery.extend({ ...@@ -715,7 +682,7 @@ jQuery.extend({
tmp = getAll( elem, "script" ); tmp = getAll( elem, "script" );
// Preserve script evaluation history // Preserve script evaluation history
if ( safe ) { if ( container ) {
setGlobalEval( tmp ); setGlobalEval( tmp );
} }
...@@ -730,8 +697,6 @@ jQuery.extend({ ...@@ -730,8 +697,6 @@ jQuery.extend({
} }
} }
elem = tmp = safe = null;
return ret; return ret;
}, },
......
...@@ -5,7 +5,7 @@ jQuery.support = (function() { ...@@ -5,7 +5,7 @@ jQuery.support = (function() {
// Setup // Setup
div.setAttribute( "className", "t" ); div.setAttribute( "className", "t" );
div.innerHTML = " <link/><table></table><a href='/a'>a</a><input type='checkbox'/>"; div.innerHTML = " <table></table><a href='/a'>a</a><input type='checkbox'/>";
// Support tests won't run in some limited or non-browser environments // Support tests won't run in some limited or non-browser environments
all = div.getElementsByTagName("*"); all = div.getElementsByTagName("*");
...@@ -31,10 +31,6 @@ jQuery.support = (function() { ...@@ -31,10 +31,6 @@ jQuery.support = (function() {
// IE will insert them into empty tables // IE will insert them into empty tables
tbody: !div.getElementsByTagName("tbody").length, tbody: !div.getElementsByTagName("tbody").length,
// Make sure that link elements get serialized correctly by innerHTML
// This requires a wrapper element in IE
htmlSerialize: !!div.getElementsByTagName("link").length,
// Get the style information from getAttribute // Get the style information from getAttribute
// (IE uses .cssText instead) // (IE uses .cssText instead)
style: /top/.test( a.getAttribute("style") ), style: /top/.test( a.getAttribute("style") ),
...@@ -62,10 +58,6 @@ jQuery.support = (function() { ...@@ -62,10 +58,6 @@ jQuery.support = (function() {
// Tests for enctype support on a form (#6743) // Tests for enctype support on a form (#6743)
enctype: !!document.createElement("form").enctype, enctype: !!document.createElement("form").enctype,
// Makes sure cloning an html5 element does not cause problems
// Where outerHTML is undefined, this still works
html5Clone: document.createElement("nav").cloneNode( true ).outerHTML !== "<:nav></:nav>",
// jQuery.support.boxModel DEPRECATED in 1.8 since we don't support Quirks Mode // jQuery.support.boxModel DEPRECATED in 1.8 since we don't support Quirks Mode
boxModel: document.compatMode === "CSS1Compat", boxModel: document.compatMode === "CSS1Compat",
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment