Commit 39c05d36 authored by Jörn Zaefferer's avatar Jörn Zaefferer

Fixed jQuery.eval (or rather, jQuery.globalEval to avoid problems with FF)

parent ef1ee513
...@@ -124,7 +124,7 @@ jQuery.fn.extend({ ...@@ -124,7 +124,7 @@ jQuery.fn.extend({
// for some weird reason, it doesn't work if the callback is ommited // for some weird reason, it doesn't work if the callback is ommited
jQuery.getScript( this.src ); jQuery.getScript( this.src );
else { else {
jQuery.eval ( this.text || this.textContent || this.innerHTML || "" ); jQuery.globalEval( this.text || this.textContent || this.innerHTML || "" );
} }
}).end(); }).end();
} }
...@@ -304,6 +304,10 @@ jQuery.extend({ ...@@ -304,6 +304,10 @@ jQuery.extend({
* Loads, and executes, a remote JavaScript file using an HTTP GET request. * Loads, and executes, a remote JavaScript file using an HTTP GET request.
* All of the arguments to the method (except URL) are optional. * All of the arguments to the method (except URL) are optional.
* *
* Warning: Safari <= 2.0.x is unable to evalulate scripts in a global
* context sychronously. If you load functions via getScript, make sure
* to call them after a delay.
*
* @example $.getScript("test.js") * @example $.getScript("test.js")
* *
* @example $.getScript("test.js", function(){ * @example $.getScript("test.js", function(){
...@@ -684,7 +688,7 @@ jQuery.extend({ ...@@ -684,7 +688,7 @@ jQuery.extend({
// If the type is "script", eval it in global context // If the type is "script", eval it in global context
if ( type == "script" ) { if ( type == "script" ) {
jQuery.eval( data ); jQuery.globalEval( data );
} }
// Get the JavaScript object, if JSON is used. // Get the JavaScript object, if JSON is used.
...@@ -727,10 +731,14 @@ jQuery.extend({ ...@@ -727,10 +731,14 @@ jQuery.extend({
return s.join("&"); return s.join("&");
}, },
// TODO document me // evalulates a script in global context
eval: function(data) { // not reliable for safari
globalEval: function(data) {
if (window.execScript) if (window.execScript)
window.execScript( data ); window.execScript( data );
else if(jQuery.browser.safari)
// safari doesn't provide a synchronous global eval
window.setTimeout( data, 0 );
else else
eval.call( window, data ); eval.call( window, data );
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment