mirror of
https://github.com/jquery/jquery.git
synced 2024-11-23 02:54:22 +00:00
Check against the type attribute of script elements retrieved through getElementsByTagName() so that only those elements of type "text/javascript" are handled by 'clean'.
Fixes #6180: jQuery.clean should not touch script tags that are not of type text/javascript
This commit is contained in:
parent
497fc9849e
commit
df7dfc2404
@ -146,7 +146,7 @@ jQuery.fn.extend({
|
|||||||
return set;
|
return set;
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
// keepData is for internal use only--do not document
|
// keepData is for internal use only--do not document
|
||||||
remove: function( selector, keepData ) {
|
remove: function( selector, keepData ) {
|
||||||
for ( var i = 0, elem; (elem = this[i]) != null; i++ ) {
|
for ( var i = 0, elem; (elem = this[i]) != null; i++ ) {
|
||||||
@ -161,7 +161,7 @@ jQuery.fn.extend({
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return this;
|
return this;
|
||||||
},
|
},
|
||||||
|
|
||||||
@ -177,7 +177,7 @@ jQuery.fn.extend({
|
|||||||
elem.removeChild( elem.firstChild );
|
elem.removeChild( elem.firstChild );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return this;
|
return this;
|
||||||
},
|
},
|
||||||
|
|
||||||
@ -322,9 +322,9 @@ jQuery.fn.extend({
|
|||||||
} else {
|
} else {
|
||||||
results = jQuery.buildFragment( args, this, scripts );
|
results = jQuery.buildFragment( args, this, scripts );
|
||||||
}
|
}
|
||||||
|
|
||||||
fragment = results.fragment;
|
fragment = results.fragment;
|
||||||
|
|
||||||
if ( fragment.childNodes.length === 1 ) {
|
if ( fragment.childNodes.length === 1 ) {
|
||||||
first = fragment = fragment.firstChild;
|
first = fragment = fragment.firstChild;
|
||||||
} else {
|
} else {
|
||||||
@ -429,18 +429,18 @@ jQuery.each({
|
|||||||
jQuery.fn[ name ] = function( selector ) {
|
jQuery.fn[ name ] = function( selector ) {
|
||||||
var ret = [], insert = jQuery( selector ),
|
var ret = [], insert = jQuery( selector ),
|
||||||
parent = this.length === 1 && this[0].parentNode;
|
parent = this.length === 1 && this[0].parentNode;
|
||||||
|
|
||||||
if ( parent && parent.nodeType === 11 && parent.childNodes.length === 1 && insert.length === 1 ) {
|
if ( parent && parent.nodeType === 11 && parent.childNodes.length === 1 && insert.length === 1 ) {
|
||||||
insert[ original ]( this[0] );
|
insert[ original ]( this[0] );
|
||||||
return this;
|
return this;
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
for ( var i = 0, l = insert.length; i < l; i++ ) {
|
for ( var i = 0, l = insert.length; i < l; i++ ) {
|
||||||
var elems = (i > 0 ? this.clone(true) : this).get();
|
var elems = (i > 0 ? this.clone(true) : this).get();
|
||||||
jQuery( insert[i] )[ original ]( elems );
|
jQuery( insert[i] )[ original ]( elems );
|
||||||
ret = ret.concat( elems );
|
ret = ret.concat( elems );
|
||||||
}
|
}
|
||||||
|
|
||||||
return this.pushStack( ret, name, insert.selector );
|
return this.pushStack( ret, name, insert.selector );
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@ -528,10 +528,12 @@ jQuery.extend({
|
|||||||
for ( i = 0; ret[i]; i++ ) {
|
for ( i = 0; ret[i]; i++ ) {
|
||||||
if ( scripts && jQuery.nodeName( ret[i], "script" ) && (!ret[i].type || ret[i].type.toLowerCase() === "text/javascript") ) {
|
if ( scripts && jQuery.nodeName( ret[i], "script" ) && (!ret[i].type || ret[i].type.toLowerCase() === "text/javascript") ) {
|
||||||
scripts.push( ret[i].parentNode ? ret[i].parentNode.removeChild( ret[i] ) : ret[i] );
|
scripts.push( ret[i].parentNode ? ret[i].parentNode.removeChild( ret[i] ) : ret[i] );
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
if ( ret[i].nodeType === 1 ) {
|
if ( ret[i].nodeType === 1 ) {
|
||||||
ret.splice.apply( ret, [i + 1, 0].concat(jQuery.makeArray(ret[i].getElementsByTagName("script"))) );
|
var jsTags = jQuery.makeArray( ret[i].getElementsByTagName( "script" )),
|
||||||
|
jsTags = jQuery.grep(jsTags, function(n, i) { return ( !n.type || n.type.toLowerCase() === "text/javascript" ) });
|
||||||
|
ret.splice.apply( ret, [i + 1, 0].concat( jsTags ));
|
||||||
}
|
}
|
||||||
fragment.appendChild( ret[i] );
|
fragment.appendChild( ret[i] );
|
||||||
}
|
}
|
||||||
@ -540,22 +542,22 @@ jQuery.extend({
|
|||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
},
|
},
|
||||||
|
|
||||||
cleanData: function( elems ) {
|
cleanData: function( elems ) {
|
||||||
var data, id, cache = jQuery.cache,
|
var data, id, cache = jQuery.cache,
|
||||||
special = jQuery.event.special,
|
special = jQuery.event.special,
|
||||||
deleteExpando = jQuery.support.deleteExpando;
|
deleteExpando = jQuery.support.deleteExpando;
|
||||||
|
|
||||||
for ( var i = 0, elem; (elem = elems[i]) != null; i++ ) {
|
for ( var i = 0, elem; (elem = elems[i]) != null; i++ ) {
|
||||||
if ( elem.nodeName && jQuery.noData[elem.nodeName.toLowerCase()] ) {
|
if ( elem.nodeName && jQuery.noData[elem.nodeName.toLowerCase()] ) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
id = elem[ jQuery.expando ];
|
id = elem[ jQuery.expando ];
|
||||||
|
|
||||||
if ( id ) {
|
if ( id ) {
|
||||||
data = cache[ id ];
|
data = cache[ id ];
|
||||||
|
|
||||||
if ( data && data.events ) {
|
if ( data && data.events ) {
|
||||||
for ( var type in data.events ) {
|
for ( var type in data.events ) {
|
||||||
if ( special[ type ] ) {
|
if ( special[ type ] ) {
|
||||||
@ -566,14 +568,14 @@ jQuery.extend({
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( deleteExpando ) {
|
if ( deleteExpando ) {
|
||||||
delete elem[ jQuery.expando ];
|
delete elem[ jQuery.expando ];
|
||||||
|
|
||||||
} else if ( elem.removeAttribute ) {
|
} else if ( elem.removeAttribute ) {
|
||||||
elem.removeAttribute( jQuery.expando );
|
elem.removeAttribute( jQuery.expando );
|
||||||
}
|
}
|
||||||
|
|
||||||
delete cache[ id ];
|
delete cache[ id ];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user