Permalink
Browse files

Fix #11323. Consistently use rscriptType in jQuery.clean()

  • Loading branch information...
1 parent 1ff284d commit f0732c1e4138342c96e35ff51d5cd681b6cfdb94 @rwaldron rwaldron committed with dmethvin Feb 10, 2012
Showing with 11 additions and 11 deletions.
  1. +8 −8 src/manipulation.js
  2. +3 −3 test/unit/manipulation.js
View
@@ -644,7 +644,8 @@ jQuery.extend({
},
clean: function( elems, context, fragment, scripts ) {
- var checkScriptType;
+ var checkScriptType, script, j,
+ ret = [];
context = context || document;
@@ -653,8 +654,6 @@ jQuery.extend({
context = context.ownerDocument || context[0] && context[0].ownerDocument || document;
}
- var ret = [], j;
-
for ( var i = 0, elem; (elem = elems[i]) != null; i++ ) {
if ( typeof elem === "number" ) {
elem += "";
@@ -762,16 +761,17 @@ jQuery.extend({
return !elem.type || rscriptType.test( elem.type );
};
for ( i = 0; ret[i]; i++ ) {
- 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] );
+ script = ret[i];
+ if ( scripts && jQuery.nodeName( script, "script" ) && (!script.type || rscriptType.test( script.type )) ) {
+ scripts.push( script.parentNode ? script.parentNode.removeChild( script ) : script );
} else {
- if ( ret[i].nodeType === 1 ) {
- var jsTags = jQuery.grep( ret[i].getElementsByTagName( "script" ), checkScriptType );
+ if ( script.nodeType === 1 ) {
+ var jsTags = jQuery.grep( script.getElementsByTagName( "script" ), checkScriptType );
ret.splice.apply( ret, [i + 1, 0].concat( jsTags ) );
}
- fragment.appendChild( ret[i] );
+ fragment.appendChild( script );
}
}
}
@@ -1243,7 +1243,7 @@ test("html(undefined)", function() {
});
var testHtml = function(valueObj) {
- expect(34);
+ expect(35);
jQuery.scriptorder = 0;
@@ -1298,7 +1298,7 @@ var testHtml = function(valueObj) {
QUnit.reset();
- jQuery("#qunit-fixture").html(valueObj("<script type='something/else'>ok( false, 'Non-script evaluated.' );</script><script type='text/javascript'>ok( true, 'text/javascript is evaluated.' );</script><script>ok( true, 'No type is evaluated.' );</script><div><script type='text/javascript'>ok( true, 'Inner text/javascript is evaluated.' );</script><script>ok( true, 'Inner No type is evaluated.' );</script><script type='something/else'>ok( false, 'Non-script evaluated.' );</script></div>"));
+ jQuery("#qunit-fixture").html(valueObj("<script type='something/else'>ok( false, 'Non-script evaluated.' );</script><script type='text/javascript'>ok( true, 'text/javascript is evaluated.' );</script><script>ok( true, 'No type is evaluated.' );</script><div><script type='text/javascript'>ok( true, 'Inner text/javascript is evaluated.' );</script><script>ok( true, 'Inner No type is evaluated.' );</script><script type='something/else'>ok( false, 'Non-script evaluated.' );</script><script type='type/ecmascript'>ok( true, 'type/ecmascript evaluated.' );</script></div>"));
var child = jQuery("#qunit-fixture").find("script");
@@ -1324,7 +1324,7 @@ test("html(String)", function() {
test("html(Function)", function() {
testHtml(functionReturningObj);
- expect(36);
+ expect(37);
QUnit.reset();

0 comments on commit f0732c1

Please sign in to comment.