aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRick Waldron waldron.rick@gmail.com <waldron.rick@gmail.com>2012-02-10 16:39:28 -0500
committerDave Methvin <dave.methvin@gmail.com>2012-03-02 13:13:43 -0500
commitf0732c1e4138342c96e35ff51d5cd681b6cfdb94 (patch)
tree02c6471864cd79215e11573f4b4ce68c9f1ccb15
parent1ff284d2cd67f2f4e7cd8b9577191ba80d521763 (diff)
downloadjquery-f0732c1e4138342c96e35ff51d5cd681b6cfdb94.tar.gz
jquery-f0732c1e4138342c96e35ff51d5cd681b6cfdb94.zip
Fix #11323. Consistently use rscriptType in jQuery.clean()
-rw-r--r--src/manipulation.js16
-rw-r--r--test/unit/manipulation.js6
2 files changed, 11 insertions, 11 deletions
diff --git a/src/manipulation.js b/src/manipulation.js
index 954d52edf..159c4c488 100644
--- a/src/manipulation.js
+++ b/src/manipulation.js
@@ -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 );
}
}
}
diff --git a/test/unit/manipulation.js b/test/unit/manipulation.js
index 21d1f5f93..717488178 100644
--- a/test/unit/manipulation.js
+++ b/test/unit/manipulation.js
@@ -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();