Skip to content
This repository has been archived by the owner on Apr 12, 2024. It is now read-only.

fix(Angular): Angular.copy shouldn't copy $$hashKey or $$* properties #2382

Closed
wants to merge 1 commit into from

Conversation

davidchang
Copy link
Contributor

Fix for this issue: #1875

I copied the code from shallowCopy in to copy so that both should be consistent. Though that issue mentioned Angular.extend also copies $$hashkey, I though that would be appropriate, somewhat expected behavior.

@spamdaemon
Copy link

I think the $$ properties need to be removed from the sources in extend() as well, since I believe the purpose of hashKey is to actually be an unique object id. After extend(a,b), you still have 2 distinct/unique objects.

@spamdaemon
Copy link

David,

Pete asked me to collaborate on this patch with you. The patch I created copies all $$ properties over, but treats the $$hashKey specially. If the target object already has a hashKey then it keeps it for both extend() and copy(). If the target object does not have a hashkey, then the hashkey is not copied.

The reason for keeping the old hashkey around is twofold:

  1. I view the hashkey as an object id and so it makes more sense to to me to not copy or delete an existing hashkey.
  2. keeping the old hashkey around when copying into an object will allow the repeater to track it and it won't treat it as a new object when copying into it (I admit that this is a questionable optimization).

I would also prefer to not copy other $$ properties for extend/copy but I'm not sure if angular's internals relied on copying $$ properties as well.

@petebacondarwin
Copy link
Contributor

Superceded by #2423. Can you work together to bring this in for both copy and extend? I'll take a look tomorrow.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants