Manipulation: Support $el.html(selfRemovingScript) (#5378)
[jquery.git] / src / core / DOMEval.js
blob21f5a463ce4e7e281d999ab9a25305d3a38f2c16
1 import { document } from "../var/document.js";
3 var preservedScriptAttributes = {
4         type: true,
5         src: true,
6         nonce: true,
7         noModule: true
8 };
10 export function DOMEval( code, node, doc ) {
11         doc = doc || document;
13         var i,
14                 script = doc.createElement( "script" );
16         script.text = code;
17         for ( i in preservedScriptAttributes ) {
18                 if ( node && node[ i ] ) {
19                         script[ i ] = node[ i ];
20                 }
21         }
23         if ( doc.head.appendChild( script ).parentNode ) {
24                 script.parentNode.removeChild( script );
25         }