Bug Tracker

Opened 7 years ago

Closed 7 years ago

Last modified 7 years ago

#14174 closed bug (notabug)

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 );
		}
	},

Change History (3)

comment:1 Changed 7 years ago by Rick Waldron

Resolution: notabug
Status: newclosed

The point of "globalEval" is to evaluate a piece of code specifically for its side effects, not to return a value.

comment:2 in reply to:  1 Changed 7 years ago by anonymous

Replying to 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!

comment:3 in reply to:  1 Changed 7 years ago by anonymous

Replying to rwaldron:

If it is not a bug, then implement it as a feature.

Note: See TracTickets for help on using tickets.