mirror of
https://github.com/jquery/jquery.git
synced 2026-02-01 16:24:57 -05:00
Ajax: Always use script injection in globalEval
Fixes #14757 Closes gh-1449
This commit is contained in:
21
src/core.js
21
src/core.js
@@ -256,25 +256,10 @@ jQuery.extend({
|
||||
|
||||
// Evaluates a script in a global context
|
||||
globalEval: function( code ) {
|
||||
var script,
|
||||
indirect = eval;
|
||||
var script = document.createElement( "script" );
|
||||
|
||||
code = jQuery.trim( code );
|
||||
|
||||
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 ) {
|
||||
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 );
|
||||
}
|
||||
}
|
||||
script.text = code;
|
||||
document.head.appendChild( script ).parentNode.removeChild( script );
|
||||
},
|
||||
|
||||
// Convert dashed to camelCase; used by the css and data modules
|
||||
|
||||
Reference in New Issue
Block a user