diff --git a/src/manipulation.js b/src/manipulation.js index dec21ea0b..64a8785e0 100644 --- a/src/manipulation.js +++ b/src/manipulation.js @@ -40,7 +40,8 @@ var // checked="checked" or checked rchecked = /checked\s*(?:[^=]|=\s*.checked.)/i, - rcleanScript = /^\s*\s*$/g; + + rcleanScript = /^\s*\s*$/g; // Prefer a tbody over its parent table for containing new rows function manipulationTarget( elem, content ) { @@ -195,6 +196,12 @@ function domManip( collection, args, callback, ignored ) { }, doc ); } } else { + + // Unwrap a CDATA section containing script contents. This shouldn't be + // needed as in XML documents they're already not visible when + // inspecting element contents and in HTML documents they have no + // meaning but we're preserving that logic for backwards compatibility. + // This will be removed completely in 4.0. See gh-4904. DOMEval( node.textContent.replace( rcleanScript, "" ), node, doc ); } } diff --git a/test/unit/manipulation.js b/test/unit/manipulation.js index 22e9ae747..3fe49aae9 100644 --- a/test/unit/manipulation.js +++ b/test/unit/manipulation.js @@ -2268,7 +2268,7 @@ QUnit.test( "domManip plain-text caching (trac-6779)", function( assert ) { QUnit.test( "domManip executes scripts containing html comments or CDATA (trac-9221)", function( assert ) { - assert.expect( 3 ); + assert.expect( 4 ); jQuery( [ "" ].join( "\n" ) ).appendTo( "#qunit-fixture" ); + + // ES2015 in Annex B requires HTML-style comment delimiters (``) to act as + // single-line comment delimiters; i.e. they should be treated as `//`. + // See gh-4904 + jQuery( [ + "" + ].join( "\n" ) ).appendTo( "#qunit-fixture" ); } ); testIframe(