[jQuery] A minor $.apply() snafu
Let's definitely avoid the PHP disease of having totally inconsistent
functions, naming, and parameter order. So far I think we have.
So $.apply exists to support those implementations that don't have
function.apply, such as IE5? How about if you just implement it as
function.apply instead?
if ( !Function.prototype.apply )
Function.prototype.apply = function(obj,args) { ... }
-----Original Message-----
From: discuss-bounces@jquery.com [mailto:discuss-bounces@jquery.com] On
Behalf Of Michael Geary
Sent: Friday, April 07, 2006 3:14 AM
To: 'jQuery Discussion.'
Subject: [jQuery] A minor $.apply() snafu
John and friends, when I submitted my patch a while back that added a
$.apply() function, I screwed up the order of the arguments. I defined the
function as:
$.apply( object, method, args )
I should have defined it as:
$.apply( method, object, args )
So, this note is a heads-up that I would like to submit another patch to
correct this. The function is not documented, so hopefully not too much code
outside of jQuery itself uses it.
Why does the argument order make any difference? In one sense, of course, it
does not. The function works fine as it is.
But there are some problems of consistency:
1) The native JavaScript apply function has the method first:
method.apply(object,args).
2) When I wrote my $.closure() method, it made the most sense to put the
method first: $.closure(method,object), because the object is optional while
the method is required.
Trivial items, to be sure, but it started to remind me of PHP, where they
can't make up their mind whether the source or destination string should
come first in the string library functions. I didn't want to be the one
responsible for bringing that kind of confusion to jQuery. :-)
So would it cause a problem for anyone if I changed the argument order for
$.apply()? I could put in a temporary hack so it would allow either the old
or new argument order for a few revisions before making the change
permanent.
Thanks,
-Mike
_______________________________________________
jQuery mailing list
discuss@jquery.com
http://jquery.com/discuss/