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

Observed TypeError - Illegal invocation exception when deep watching an object containing FileList object. #13924

Closed
vinayk406 opened this issue Feb 2, 2016 · 3 comments

Comments

@vinayk406
Copy link

Browser : chrome
Angular Version : 1.4.8

Plnkr: https://plnkr.co/edit/EjTuiuG9LXaEm2KUnThn?p=preview

Exception in firefox: 'name' getter called on an object that does not implement interface File.

@gkalpak
Copy link
Member

gkalpak commented Feb 2, 2016

This happens because you are using deep equality. As mentioned in the docs, using objectEquality: true will copy the object (so it can compare it with subsequent values and detect changes) using angular.copy() (and watching complex objects can have adverse implications).

File objects can't be properly copied, thus the error. You could use "normal" (non-deep) watch on the file-list itself or shallow watch details using $watchCollection(): Updated plnkr

@vinayk406
Copy link
Author

As the watch expression in my case is dynamic, neither can use $watchCollection nor normal watch.
Why can't the framework ignore the copying of Special Objects(FileList in this case) in the deep watch scenario and compare only on the references?

@gkalpak
Copy link
Member

gkalpak commented Apr 7, 2016

Closing as duplicate of #14352 (well, it's the other way around, but #14352 has more participants 😃).
Let's track the issue there.

@gkalpak gkalpak closed this as completed Apr 7, 2016
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