@@ -10,26 +10,29 @@ define( [
1010 noModule : true
1111 } ;
1212
13- function DOMEval ( code , doc , node ) {
13+ function DOMEval ( code , node , doc ) {
1414 doc = doc || document ;
1515
16- var i ,
16+ var i , val ,
1717 script = doc . createElement ( "script" ) ;
1818
1919 script . text = code ;
2020 if ( node ) {
2121 for ( i in preservedScriptAttributes ) {
22- if ( node [ i ] ) {
23- script [ i ] = node [ i ] ;
24- } else if ( node . getAttribute ( i ) ) {
2522
26- // Support: Firefox 64+, Edge 18+
27- // Some browsers don't support the "nonce" property on scripts.
28- // On the other hand, just using `setAttribute` & `getAttribute`
29- // is not enough as `nonce` is no longer exposed as an attribute
30- // in the latest standard.
31- // See https://github.com/whatwg/html/issues/2369
32- script . setAttribute ( i , node . getAttribute ( i ) ) ;
23+ // Support: Firefox 64+, Edge 18+
24+ // Some browsers don't support the "nonce" property on scripts.
25+ // On the other hand, just using `getAttribute` is not enough as
26+ // the `nonce` attribute is reset to an empty string whenever it
27+ // becomes browsing-context connected.
28+ // See https://github.com/whatwg/html/issues/2369
29+ // See https://html.spec.whatwg.org/#nonce-attributes
30+ // The `node.getAttribute` check was added for the sake of
31+ // `jQuery.globalEval` so that it can fake a nonce-containing node
32+ // via an object.
33+ val = node [ i ] || node . getAttribute && node . getAttribute ( i ) ;
34+ if ( val ) {
35+ script . setAttribute ( i , val ) ;
3336 }
3437 }
3538 }
0 commit comments