aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJohn Resig <jeresig@gmail.com>2007-07-31 02:59:53 +0000
committerJohn Resig <jeresig@gmail.com>2007-07-31 02:59:53 +0000
commit6b0d3bb273f09910921ed84539de06c2e7ecd19b (patch)
treeab670da3506c350d7a789d3d19a14ef5ea188dc3
parent4ae80a1e2cfe7445501e8f365d72417014cf1acb (diff)
downloadjquery-6b0d3bb273f09910921ed84539de06c2e7ecd19b.tar.gz
jquery-6b0d3bb273f09910921ed84539de06c2e7ecd19b.zip
Brought back jQuery.globalEval(), fixing bug #1425.
-rw-r--r--src/ajax/ajax.js2
-rw-r--r--src/jquery/jquery.js17
2 files changed, 17 insertions, 2 deletions
diff --git a/src/ajax/ajax.js b/src/ajax/ajax.js
index 645caf72e..392ea16ef 100644
--- a/src/ajax/ajax.js
+++ b/src/ajax/ajax.js
@@ -765,7 +765,7 @@ jQuery.extend({
// If the type is "script", eval it in global context
if ( type == "script" )
- (new Function( data ))();
+ jQuery.globalEval( data );
// Get the JavaScript object, if JSON is used.
if ( type == "json" )
diff --git a/src/jquery/jquery.js b/src/jquery/jquery.js
index a0a200993..440e20e98 100644
--- a/src/jquery/jquery.js
+++ b/src/jquery/jquery.js
@@ -1191,7 +1191,7 @@ jQuery.fn = jQuery.prototype = {
if ( this.src )
jQuery.ajax({ url: this.src, async: false, dataType: "script" });
else
- (new Function( this.text || this.textContent || this.innerHTML || "" ))();
+ jQuery.globalEval( this.text || this.textContent || this.innerHTML || "" );
} else
fn.apply( obj, [ clone ? this.cloneNode(true) : this ] );
});
@@ -1322,6 +1322,21 @@ jQuery.extend({
elem.tagName && elem.ownerDocument && !elem.ownerDocument.body;
},
+ // Evalulates a script in a global context
+ // Evaluates Async. in Safari 2 :-(
+ globalEval: function( data ) {
+ data = jQuery.trim( data );
+ if ( data ) {
+ if ( window.execScript )
+ window.execScript( data );
+ else if ( jQuery.browser.safari )
+ // safari doesn't provide a synchronous global eval
+ window.setTimeout( data, 0 );
+ else
+ eval.call( window, data );
+ }
+ },
+
nodeName: function( elem, name ) {
return elem.nodeName && elem.nodeName.toUpperCase() == name.toUpperCase();
},