aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/manipulation.js6
-rw-r--r--test/data/cleanScript.html4
-rw-r--r--test/unit/manipulation.js24
3 files changed, 22 insertions, 12 deletions
diff --git a/src/manipulation.js b/src/manipulation.js
index f86bd9ab0..19c60fcbc 100644
--- a/src/manipulation.js
+++ b/src/manipulation.js
@@ -25,9 +25,7 @@ var
// Support: IE <=10 - 11+
// In IE using regex groups here causes severe slowdowns.
- rnoInnerhtml = /<script|<style|<link/i,
-
- rcleanScript = /^\s*<!(?:\[CDATA\[|--)|(?:\]\]|--)>\s*$/g;
+ rnoInnerhtml = /<script|<style|<link/i;
// Prefer a tbody over its parent table for containing new rows
function manipulationTarget( elem, content ) {
@@ -161,7 +159,7 @@ function domManip( collection, args, callback, ignored ) {
}, doc );
}
} else {
- DOMEval( node.textContent.replace( rcleanScript, "" ), node, doc );
+ DOMEval( node.textContent, node, doc );
}
}
}
diff --git a/test/data/cleanScript.html b/test/data/cleanScript.html
index c37694aac..60d235b82 100644
--- a/test/data/cleanScript.html
+++ b/test/data/cleanScript.html
@@ -4,7 +4,7 @@ QUnit.assert.ok( true, "script within html comments executed" );
-->
</script>
<script>
-<![CDATA[
+<!--//--><![CDATA[//><!--
QUnit.assert.ok( true, "script within CDATA executed" );
-]]>
+//--><!]]>
</script>
diff --git a/test/unit/manipulation.js b/test/unit/manipulation.js
index 131109448..8262516a9 100644
--- a/test/unit/manipulation.js
+++ b/test/unit/manipulation.js
@@ -2233,19 +2233,31 @@ QUnit.test( "domManip executes scripts containing html comments or CDATA (trac-9
"</script>"
].join( "\n" ) ).appendTo( "#qunit-fixture" );
+ // This test requires XHTML mode as CDATA is not recognized in HTML.
+ // jQuery( [
+ // "<script type='text/javascript'>",
+ // "<![CDATA[",
+ // "QUnit.assert.ok( true, '<![CDATA[ handled' );",
+ // "//]]>",
+ // "</script>"
+ // ].join( "\n" ) ).appendTo( "#qunit-fixture" );
+
jQuery( [
"<script type='text/javascript'>",
- "<![CDATA[",
- "QUnit.assert.ok( true, '<![CDATA[ handled' );",
- "//]]>",
+ "<!--//--><![CDATA[//><!--",
+ "QUnit.assert.ok( true, '<!--//--><![CDATA[//><!-- (Drupal case) handled' );",
+ "//--><!]]>",
"</script>"
].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( [
"<script type='text/javascript'>",
- "<!--//--><![CDATA[//><!--",
- "QUnit.assert.ok( true, '<!--//--><![CDATA[//><!-- (Drupal case) handled' );",
- "//--><!]]>",
+ "<!-- Same-line HTML comment",
+ "QUnit.assert.ok( true, '<!-- Same-line HTML comment' );",
+ "-->",
"</script>"
].join( "\n" ) ).appendTo( "#qunit-fixture" );
} );