-
Notifications
You must be signed in to change notification settings - Fork 27.4k
feat(angular.extend) - Simple non-breaking change to support deep extend #10507
Conversation
CLAs look good, thanks! |
Is there a way to rerun the job that failed? It's a timeout, not an explicit (test) failure. |
git commit --amend --date "`date -R`"
git push -f |
also, please squash all the commits into one |
var h = dst.$$hashKey; | ||
var h = dst.$$hashKey, | ||
argsLength = arguments.length, | ||
isDeep = (argsLength >= 3) && (arguments[argsLength - 1] === true); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: each of these declarations should have its own var
for clarity
simple question, why is it that |
I think I don't see a huge problem with adding this, not to say that there aren't things I dislike about it. |
Oh, I should add that |
@petebacondarwin what's your opinion? Normally we just tell people to "use lodash", but it's not a very big change, I don't really see the harm in this one |
dst[key] = obj[key]; | ||
var src = obj[key]; | ||
|
||
if (isDeep && Object.keys(src).length) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If the value is null
or undefined
, Object.keys() will throw here... Don't worry about checking the type I guess, it's fine
I'm afraid I may be in over my head here. Tried to squash the multiple commit (sorry) into one via this, but I'm still seeing multiple commits: git rebase -i HEAD~8 |
@prettycode what do you see when you run |
delete arguments[argsLength - 1]; | ||
} | ||
|
||
for (var i = 1; i < argsLength; i++) { | ||
var obj = arguments[i]; | ||
if (obj) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You misunderstood me in that last commit --- I mean on line 353, the condition should not be if (obj)
, it should be if (isObject(obj) || isFunction(obj))
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Make this change, please.
Thanks for your help, caitp! Sorry for my inexperience with git. Updating tests and the |
@caitp - Oh go on then :-) |
|
||
for (var i = 1, ii = arguments.length; i < ii; i++) { | ||
if (isDeep) { | ||
delete arguments[argsLength - 1]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if (isDeep) --argsLength;
We don't need to delete anything, it's slow, and deleting the argument doesn't really do anything meaningful (it doesn't change the length value). I said this in like the first 3 comments =)
dst[key] = obj[key]; | ||
var src = obj[key]; | ||
|
||
if (isDeep && isObject(dst[key])) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If dst[key]
is anything other than an object, we really need to replace it with an object --- I think copy()
will use an Array if the source is an array, too.
Closing in favour of #10519 |
…merges 'deeply' Closes angular#10507 Closes angular#10519
…merges 'deeply' Closes angular#10507 Closes angular#10519
People use
angular.extend()
as a utility function, whether or not it's designed for that purpose. It can easily be extended to support recursive merging with very very minor additions. Developers coming to Angular expectextend()
to support this.