Skip to main content

Bug Tracker

Side navigation

#14191 closed feature (cantfix)

Opened July 27, 2013 01:53AM UTC

Closed August 27, 2013 05:37PM UTC

Improvements to jQuery.globalEval

Reported by: brian Owned by:
Priority: undecided Milestone: None
Component: unfiled Version:
Keywords: Cc:
Blocked by: Blocking:
Description

jQuery.globalEval can definitely be useful, but why not make it even more powerful?

jsFiddle: http://jsfiddle.net/UYH97/6/

One feature that can be useful in a global eval function is a return value. This article says that jQuery "sacrifices return value for a more extensive browser support." But why stop at one when you can have both? I have been able to modify the $.globalEval function so that it provides a correct return value in all browsers - even IE 6! This is showcased in the jsFiddle demo listed above.

Another feature that I thought might be useful would be the ability to evaluate code in an iframe or external window created using window.open by implementing an optional "context" parameter. This worked in all browsers except, of course, IE. However, I was only able to test it in IE 6 and 8, both of which, I recognize, are no longer supported by the jQuery library. More info on test results can be found in the jsFiddle.

Attachments (0)
Change History (5)

Changed July 27, 2013 02:09AM UTC by anonymous comment:1

Sorry - I forgot to include a link. By "this article" I mean: http://perfectionkills.com/global-eval-what-are-the-options/#global_eval_in_libraries

Changed August 06, 2013 02:35AM UTC by dmethvin comment:2

Since globalEval is by definition in the global scope, I'm not sure why we even look for "use strict".

IE 6/7/8 are supported by the 1.x-master branch and we're reluctant to apply patches that cause behavior differences across the two branches.

Changed August 07, 2013 07:38PM UTC by anonymous comment:3

Replying to [comment:2 dmethvin]:

IE 6/7/8 are supported by the 1.x-master branch and we're reluctant to apply patches that cause behavior differences across the two branches.

Implementation of the return value, at least, is both useful and backward-compatible.

Changed August 17, 2013 07:48PM UTC by Brian comment:4

Replying to [comment:2 dmethvin]:

Okay, I've removed the context param from the code. The new jsFiddle can be found here: http://jsfiddle.net/UYH97/7/. It works in all browsers tested. Now, the only question is, do you want this added feature or not?

Changed August 27, 2013 05:37PM UTC by markelog comment:5

resolution: → cantfix
status: newclosed

Only execScript method could execute eval code in global namespace in oldIE. Which even mention by the kangax article that you provided –

IE<=8 executes code in the scope of a caller, as if indirect call was direct one