diff --git a/src/manipulation.js b/src/manipulation.js index 758cdbae..52d59d83 100644 --- a/src/manipulation.js +++ b/src/manipulation.js @@ -9,6 +9,7 @@ var rinlinejQuery = / jQuery\d+="(?:\d+|null)"/g, rnocache = /<(?:script|object|embed|option|style)/i, // checked="checked" or checked rchecked = /checked\s*(?:[^=]|=\s*.checked.)/i, + rscriptType = /\/(java|ecma)script/i, wrapMap = { option: [ 1, "" ], legend: [ 1, "
", "
" ], @@ -635,7 +636,11 @@ jQuery.extend({ } else { if ( ret[i].nodeType === 1 ) { - ret.splice.apply( ret, [i + 1, 0].concat(jQuery.makeArray(ret[i].getElementsByTagName("script"))) ); + var jsTags = jQuery.grep( ret[i].getElementsByTagName( "script" ), function( elem ) { + return !elem.type || rscriptType.test( elem.type ); + }); + + ret.splice.apply( ret, [i + 1, 0].concat( jsTags ) ); } fragment.appendChild( ret[i] ); } diff --git a/test/unit/manipulation.js b/test/unit/manipulation.js index 64265c9b..de65daa1 100644 --- a/test/unit/manipulation.js +++ b/test/unit/manipulation.js @@ -1058,7 +1058,7 @@ test("clone() on XML nodes", function() { } var testHtml = function(valueObj) { - expect(31); + expect(34); jQuery.scriptorder = 0; @@ -1115,6 +1115,12 @@ var testHtml = function(valueObj) { jQuery("#main").html(valueObj("
")); + var child = jQuery("#main").find("script"); + + equals( child.length, 2, "Make sure that two non-JavaScript script tags are left." ); + equals( child[0].type, "something/else", "Verify type of script tag." ); + equals( child[1].type, "something/else", "Verify type of script tag." ); + jQuery("#main").html(valueObj("")); jQuery("#main").html(valueObj("")); jQuery("#main").html(valueObj("")); @@ -1133,7 +1139,7 @@ test("html(String)", function() { test("html(Function)", function() { testHtml(functionReturningObj); - expect(33); + expect(36); QUnit.reset();