… prologue position strict mode pragma Signed-off-by: Rick Waldron <waldron.rick@gmail.com>
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -515,10 +515,25 @@ jQuery.extend({ | ||
noop: function() {}, | ||
|
||
// Evaluates a script in a global context | ||
globalEval: function( data ) { | ||
var indirect = eval; | ||
if ( jQuery.trim( data ) ) { | ||
indirect( data + ";" ); | ||
globalEval: function( code ) { | ||
var script, | ||
indirect = eval; | ||
|
||
code = jQuery.trim( code ) + ";"; | ||
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong.
rwaldron
Author
Member
|
||
|
||
if ( code ) { | ||
// If the code includes a valid, prologue position | ||
// strict mode pragma, execute code by injecting a | ||
// script tag into the document. | ||
if ( code.indexOf("use strict") === 1 ) { | ||
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong. |
||
script = document.createElement("script"); | ||
script.text = code; | ||
document.head.appendChild( script ).parentNode.removeChild( script ); | ||
} else { | ||
// Otherwise, avoid the DOM node creation, insertion | ||
// and removal by using an indirect global eval | ||
indirect( code ); | ||
} | ||
} | ||
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong.
rwaldron
Author
Member
|
||
}, | ||
|
||
1 comment
on commit feea939
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Related, cujojs/curl.
I've see the
";"
was there previously too. What's the reason it's required?