diff options
author | Dave Methvin <dave.methvin@gmail.com> | 2011-04-07 11:30:26 -0400 |
---|---|---|
committer | Dave Methvin <dave.methvin@gmail.com> | 2011-04-07 11:30:26 -0400 |
commit | c470db6950d05644fa9d99e79ce0b2bc3c6235a1 (patch) | |
tree | c705fb8faf36df1d531dc3f81c3ac1dd959bbc03 /src/core.js | |
parent | 14193e449efe76105df61d745ebd7031dd7fe783 (diff) | |
parent | 6832595ccd41d26f1c5c96ccabeee4ba6e53e1f6 (diff) | |
download | jquery-c470db6950d05644fa9d99e79ce0b2bc3c6235a1.tar.gz jquery-c470db6950d05644fa9d99e79ce0b2bc3c6235a1.zip |
Merge branch 'master' of github.com:jquery/jquery
Diffstat (limited to 'src/core.js')
-rw-r--r-- | src/core.js | 27 |
1 files changed, 10 insertions, 17 deletions
diff --git a/src/core.js b/src/core.js index b81fa7644..3331969a3 100644 --- a/src/core.js +++ b/src/core.js @@ -565,24 +565,17 @@ jQuery.extend({ noop: function() {}, - // Evalulates a script in a global context + // Evaluates a script in a global context + // Workarounds based on findings by Jim Driscoll + // http://weblogs.java.net/blog/driscoll/archive/2009/09/08/eval-javascript-global-context globalEval: function( data ) { - if ( data && rnotwhite.test(data) ) { - // Inspired by code by Andrea Giammarchi - // http://webreflection.blogspot.com/2007/08/global-scope-evaluation-and-dom.html - var head = document.head || document.getElementsByTagName( "head" )[0] || document.documentElement, - script = document.createElement( "script" ); - - if ( jQuery.support.scriptEval() ) { - script.appendChild( document.createTextNode( data ) ); - } else { - script.text = data; - } - - // Use insertBefore instead of appendChild to circumvent an IE6 bug. - // This arises when a base node is used (#2709). - head.insertBefore( script, head.firstChild ); - head.removeChild( script ); + if ( data && rnotwhite.test( data ) ) { + // We use execScript on Internet Explorer + // We use an anonymous function so that context is window + // rather than jQuery in Firefox + ( window.execScript || function( data ) { + window[ "eval" ].call( window, data ); + } )( data ); } }, |