aboutsummaryrefslogtreecommitdiffstats
path: root/src/core
diff options
context:
space:
mode:
authorRichard Gibson <richard.gibson@gmail.com>2024-01-08 12:30:39 -0500
committerGitHub <noreply@github.com>2024-01-08 18:30:39 +0100
commit937923d9ee8dfd19008447b5059cbd13ee5a23ac (patch)
tree07f1aaa7840258ddf6b87ed8506f52adadec9525 /src/core
parente8b7db4b0f1e1b8e08578641b30a92b955ccc4ec (diff)
downloadjquery-937923d9ee8dfd19008447b5059cbd13ee5a23ac.tar.gz
jquery-937923d9ee8dfd19008447b5059cbd13ee5a23ac.zip
Manipulation: Support $el.html(selfRemovingScript) (#5378)
Don't try to remove a script element that has already removed itself. Also, compress `DOMEval.js`. Fixes gh-5377 Closes gh-5378
Diffstat (limited to 'src/core')
-rw-r--r--src/core/DOMEval.js13
1 files changed, 7 insertions, 6 deletions
diff --git a/src/core/DOMEval.js b/src/core/DOMEval.js
index 806f29ebe..21f5a463c 100644
--- a/src/core/DOMEval.js
+++ b/src/core/DOMEval.js
@@ -14,12 +14,13 @@ export function DOMEval( code, node, doc ) {
script = doc.createElement( "script" );
script.text = code;
- if ( node ) {
- for ( i in preservedScriptAttributes ) {
- if ( node[ i ] ) {
- script[ i ] = node[ i ];
- }
+ for ( i in preservedScriptAttributes ) {
+ if ( node && node[ i ] ) {
+ script[ i ] = node[ i ];
}
}
- doc.head.appendChild( script ).parentNode.removeChild( script );
+
+ if ( doc.head.appendChild( script ).parentNode ) {
+ script.parentNode.removeChild( script );
+ }
}