Ajax: Always use script injection in globalEval

Fixes #14757
Closes gh-1449
This commit is contained in:
Oleg Gaidarenko
2013-11-29 12:15:05 +04:00
parent e488d985cf
commit bbdfbb4ee8
6 changed files with 42 additions and 48 deletions

View File

@@ -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