Skip to content

Conversation

@mgreter
Copy link

@mgreter mgreter commented Jul 19, 2012

jQuery currently does not have a curry function. Proxy does support arguments currying but will always overwrite the context. Sometimes I would like to only curry some arguments without setting an explicit context.

I'm not sure if this already has been suggested, as the change is very small and quite obvious. This enables me to use it to only curry arguments without an explicit context:

var cb = jQuery.proxy(fn, null, 'arg1', 'arg2');
cb.call(myobject, 'arg3');

The patch is very small and will not overwrite the context if it evaluates to false. Maybe this check should be more strict (typeof context == 'undefined' ? this : context)? I don't see a valid reason to set the context to something that evaluates to false!? What do you think?

Thanks for consideration and your time!
Have a nice day!

@rwaldron
Copy link
Member

Is there a ticket associated to this? If not, please file at http://bugs.jquery.com. Additionally, you'll need to provide test cases that support the change. Thanks!

@scottgonzalez
Copy link
Member

I wonder if there are people intentionally passing null to get the methods to run in the global context. I doubt it, but it's something to be aware of if this lands.

@jaubourg
Copy link
Member

What @scottgonzalez says. It's a breaking change so what @rwldrn says, let's start with a ticket to discuss this and get a clear view at what it entails ;)

@mgreter
Copy link
Author

mgreter commented Jul 19, 2012

Thanks for your replies. I hope it wasn't rude to create this pull request.
I opened a ticket here: http://bugs.jquery.com/ticket/12107

@jaubourg
Copy link
Member

How could a pull request be rude? Don't worry, we love pull requests! :)

We're just trying to ensure no one works hard on a pull request just to see it rejected. The idea is to create a ticket to get proper and extensive discussion then to see the idea green-lighted or rejected. Then, if the idea is accepted, code can be safely produced and reviewed. We're just trying to avoid a lot of frustrations here ;)

@rwaldron
Copy link
Member

+1 @jaubourg

Tickets also give us a history, so if something is no good, we can point the next person to the ticket, instead of re-explaining from scratch.

@dmethvin
Copy link
Member

I don't see a valid reason to set the context to something that evaluates to false!?

Since the this argument always is promoted to an object anyway, it would be crazy! CRAZY I tell you. So that probably means someone is doing it. I sure wish we still had Google Codesearch. But it seems like this should be a safe change.

@dmethvin dmethvin closed this in de9ff7c Oct 21, 2012
@dmethvin
Copy link
Member

Thanks @mgreter! If you'll fill out the CLA I'll be happy to add you to the AUTHORS.txt file.

@staabm
Copy link
Contributor

staabm commented Oct 21, 2012

Should this "new signature" be backed up by a unit test?

@dmethvin
Copy link
Member

@mgreter
Copy link
Author

mgreter commented Oct 22, 2012

@dmethvin : I signed the CLA yesterday. Just tell me if you need anything else!?

mescoda pushed a commit to mescoda/jquery that referenced this pull request Nov 4, 2014
@lock lock bot locked as resolved and limited conversation to collaborators Jan 21, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Development

Successfully merging this pull request may close these issues.

6 participants