Side navigation
#14174 closed bug (notabug)
Opened July 23, 2013 11:12PM UTC
Closed July 23, 2013 11:27PM UTC
Last modified July 24, 2013 02:28AM UTC
globalEval return value
Reported by: | anonymous | Owned by: | |
---|---|---|---|
Priority: | undecided | Milestone: | None |
Component: | unfiled | Version: | 1.10.2 |
Keywords: | Cc: | ||
Blocked by: | Blocking: |
Description
Unlike JavaScript's native eval function, jQuery.globalEval has no return value. It appears that this can be fixed (in FireFox, at least) by simply adding a couple of "returns":
globalEval: function( data ) { if ( data && jQuery.trim( data ) ) { // We use execScript on Internet Explorer // We use an anonymous function so that context is window // rather than jQuery in Firefox return ( window.execScript || function( data ) { return window[ "eval" ].call( window, data ); } )( data ); } },
Attachments (0)
Change History (3)
Changed July 23, 2013 11:27PM UTC by comment:1
resolution: | → notabug |
---|---|
status: | new → closed |
Changed July 24, 2013 02:22AM UTC by comment:2
Replying to [comment:1 rwaldron]:
The point of "globalEval" is to evaluate a piece of code specifically for its side effects, not to return a value.
Okay, you can at least mention that in the documentation! "This method behaves differently from using a normal JavaScript eval() in that it's executed within the global context" implies that it is the same in every other way. The native JavaScript eval() returns a value, so why shouldn't globalEval? Trust me when I say that there are uses for it. I've even provided code to implement it!
Changed July 24, 2013 02:28AM UTC by comment:3
Replying to [comment:1 rwaldron]:
If it is not a bug, then implement it as a feature.
The point of "globalEval" is to evaluate a piece of code specifically for its side effects, not to return a value.