-
Notifications
You must be signed in to change notification settings - Fork 53
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
_.clone(...) modifies target and context #56
Comments
Not sure, but you can work around it by passing the context as: On Wed, 24 Feb 2016 at 09:50 Stefan Kleeschulte notifications@github.com
|
Yep, that's what I do now. But for me this was unexpected behaviour. I created a pull request to change it if you think there is no reason for the |
I think that we should keep the original behaviour here. If this were intended to be any data type it would not default to |
If the argument has to be an object there should rather be a check like this:
But there doesn't seem to be any problem with passing non-object values to context:
This runs without any problems, and I can access the value 1 in a custom validator:
Even |
My comment above was referring to the default value of the
I'd prefer to update the documentation instead of the behaviour here. The rationale of this code is that we can't assume that the client will not mutate the context object after passing it as an argument. Personally I don't know if this is necessary, but I don't see any reason to introduce a breaking change here. |
These lines (core.js lines 118-119) modify the
target
andcontext
parameters:This breaks for example passing a bookshelf model instance as context. After the model instance went through
_.clone
, it doesn't have aget
method anymore. Is there a specific reason for using_.clone
here? I think these statements should be replaced bytarget || {}
andcontext || {}
- the user can still decide to use_.clone
.The text was updated successfully, but these errors were encountered: