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

angular.copy loses own non-enumerable properties #15692

Closed
zuzusik opened this issue Feb 8, 2017 · 1 comment
Closed

angular.copy loses own non-enumerable properties #15692

zuzusik opened this issue Feb 8, 2017 · 1 comment

Comments

@zuzusik
Copy link
Contributor

zuzusik commented Feb 8, 2017

Do you want to request a feature or report a bug?

Report a bug.

What is the current behavior?

angular.copy uses as destination object created from prototype, which it then populates with own object properties.
This way it loses own not enumerable properties which can cause bugs.

Demo : https://jsfiddle.net/zuzusik/7ye3m006/

What is the expected behavior?

Angular doesn't lose non-enumerable properties. I assume this can be achieved by iterating through Object.getOwnPropertyNames instead of using for (key in source) loop and checking for hasOwnProperty.

What is the motivation / use case for changing the behavior?

This causes bug with JSData v3: https://jsfiddle.net/zuzusik/6evanz3g/
Details: js-data/js-data#442

Which versions of AngularJS

Angular 1.6.2, any browser.

@zuzusik zuzusik changed the title Angular loses own non-enumerable properties during digest cycle dirty checking angular.copy loses own non-enumerable properties Feb 8, 2017
zuzusik added a commit to zuzusik/angular.js that referenced this issue Feb 8, 2017
copying object without own non-enumerable properties can lead to bugs when enumerable properties
depend on non-enumerable

fixes angular#15692
zuzusik added a commit to zuzusik/angular.js that referenced this issue Feb 8, 2017
copying object without own non-enumerable properties can lead to bugs when enumerable properties
depend on non-enumerable

fixes angular#15692
zuzusik added a commit to zuzusik/angular.js that referenced this issue Feb 8, 2017
copying object without own non-enumerable properties can lead to bugs when enumerable properties
depend on non-enumerable

fixes angular#15692
zuzusik added a commit to zuzusik/angular.js that referenced this issue Feb 9, 2017
copying object without own non-enumerable properties can lead to bugs when enumerable properties
depend on non-enumerable

fixes angular#15692
zuzusik added a commit to zuzusik/angular.js that referenced this issue Feb 9, 2017
copying object without own non-enumerable properties can lead to bugs when enumerable properties
depend on non-enumerable

fixes angular#15692
zuzusik added a commit to zuzusik/angular.js that referenced this issue Feb 9, 2017
copying object without own non-enumerable properties is non-consistent and can lead to bugs

fixes angular#15692
@Narretz Narretz modified the milestones: Backlog, 1.6.x Feb 13, 2017
@Narretz
Copy link
Contributor

Narretz commented Jul 4, 2017

This has been documented as a "known issue": 14519f8 and changing this would impact existing apps. See #14853 for more discussion.

@Narretz Narretz closed this as completed Jul 4, 2017
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

2 participants