]> source.dussan.org Git - jquery.git/commitdiff
Manipulation: Generalize a test to support IE
authorRichard Gibson <richard.gibson@gmail.com>
Fri, 12 Jan 2024 23:19:33 +0000 (18:19 -0500)
committerGitHub <noreply@github.com>
Fri, 12 Jan 2024 23:19:33 +0000 (00:19 +0100)
Ref gh-5378
Closes gh-5391

test/unit/manipulation.js

index b40ba6056a7dd2fec508881c0012fa4efec7b975..8be07c1df0b6176531bcfeaaa480bea4050674c2 100644 (file)
@@ -1826,11 +1826,25 @@ QUnit.test( "html(self-removing script) (gh-5377)", function( assert ) {
 
        $fixture.html(
                [
-                       "<script>document.currentScript.parentNode.removeChild( document.currentScript ); QUnit.assert.ok( true, 'removed document.currentScript' );</script>",
+                       "<script id='gh5377-1'>",
+                               "(function removeScript() {",
+                                       "var id = 'gh5377-1';",
+                                       "var script = document.currentScript || document.getElementById(id);",
+                                       "script.parentNode.removeChild( script );",
+                                       "QUnit.assert.ok( true, 'removed document.currentScript' );",
+                               "})();",
+                       "</script>",
                        "<div>",
-                               "<script>document.currentScript.parentNode.removeChild( document.currentScript ); QUnit.assert.ok( true, 'removed inner document.currentScript' );</script>",
+                               "<script id='gh5377-2'>",
+                                       "(function removeInnerScript() {",
+                                               "var id = 'gh5377-2';",
+                                               "var innerScript = document.currentScript || document.getElementById(id);",
+                                               "innerScript.parentNode.removeChild( innerScript );",
+                                               "QUnit.assert.ok( true, 'removed inner document.currentScript' );",
+                                       "})();",
+                               "</script>",
                        "</div>"
-               ].join( "" )
+               ].join( "\n" )
        );
 } );