-
Notifications
You must be signed in to change notification settings - Fork 2.7k
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
Fix deepClone property accessor for an special case #4039
Conversation
@Hugome: Thank you for submitting a pull request! Before we can merge it, you'll need to sign the Meteor Contributor Agreement here: https://contribute.meteor.com/ |
Perhaps we should just unconditionally |
Your are right, plus deleting non existent property doesn't throw any kind of error/exception. |
@benhjames @Hugome Unfortunately I tested and found this PR would severely slow down the JS running in browser. Without As far as I see the 2.4.2 works fine with the old deepClone. Is it necessary to change it to the new one? |
If it is not an option to switch back to the old deepClone, I propose to use this: if (Object.hasOwnProperty.call(desc, 'get')) delete desc.get
if (Object.hasOwnProperty.call(desc, 'set')) delete desc.set Somehow I still feel this is a little bit slower than the old implementation of deep clone, but at least it will handle the |
I have trouble believing that a |
I did more tests and now I guess it is not the Sorry for that misleading. Will dig more. And again, in fact the old implementation works fine. |
One thing we can do is not worry about symbol properties or non-enumerable keys, since the previous |
#4039 (comment) The previous fclone implementation didn't bother with non-enumerable or non-string keys, either, so this is not a breaking change. The Date case was also a bit overzealous, since there are no actual use cases in this codebase that require Date objects to be duplicated, rather than simply passing them through. If we're missing any cases that anyone cares about, we can easily expand the switch-case coverage in the future.
#4039 (comment) The previous fclone implementation also did not preserve non-enumerable or non-string keys, so this is not a breaking change. The Date case was also a bit overzealous, since there are no actual use cases in this codebase that require Date objects to be duplicated, rather than simply passing them through. If we're missing any cases that anyone cares about, we can easily expand the switch-case coverage in the future.
In add to the previous commit :
![image](https://user-images.githubusercontent.com/1301995/47383870-edd88b00-d705-11e8-8c42-e7267e923276.png)
e1f8da4
To cover special case when the key set/get exist but == undefined :