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

angular.copy throws error if source don't have Object prototype #10114

Closed
mohsen1 opened this issue Nov 18, 2014 · 3 comments
Closed

angular.copy throws error if source don't have Object prototype #10114

mohsen1 opened this issue Nov 18, 2014 · 3 comments

Comments

@mohsen1
Copy link
Contributor

mohsen1 commented Nov 18, 2014

In Angular 1.3.2 following throws an error:

var o = Object.create(null)
o.name = "my obj";
angular.copy(o);

Error thrown:

Uncaught TypeError: undefined is not a functionmessage: "undefined is not a function"stack: (...)get stack: function () { [native code] }set stack: function () { [native code] }__proto__: Error

Line of code related

@mohsen1
Copy link
Contributor Author

mohsen1 commented Nov 18, 2014

I just opened #10116 to fix this.

@gkalpak
Copy link
Member

gkalpak commented Nov 18, 2014

I am not sure if helper functions (like copy(), forEach() etc) are supposed to support objects created with Object.create(null) (such as those created by Angular's internal createMap()), but fixing copy() and forEach() seems fairly trivial:

Replace xyz.hasOwnProperty(...) with hasOwnProperty.call(xyz, ...) in here and there.
(Note that both fixes are necessary for copy(),since it might call forEach() internally.)
Seems like you already did 😃

mohsen1 added a commit to swagger-api/swagger-editor that referenced this issue Nov 19, 2014
@lgalfaso lgalfaso added this to the Backlog milestone Nov 19, 2014
@Narretz
Copy link
Contributor

Narretz commented Sep 23, 2015

This is fixed since 1.4

@Narretz Narretz closed this as completed Sep 23, 2015
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

5 participants