-
Notifications
You must be signed in to change notification settings - Fork 27.5k
angular.copy doesn't copy File object correctly #14352
Comments
I would like to know what the expectations of supporting this are. If the expectations are that if should be able to take a Note: |
Aren't files from |
I'm implementing image editor on client side and user can edit image or use original file without changes. In the first case, after converting canvas to blob my code pass Blob object to other functions and everything is working fine. But in the second case, when user skip changes, I have File object, which is similar to Blob in all cases, except that angular.copy doesn't copy it. |
The thing is that In other words: You should not use There is still a limitation (that should be addressed one way or another), when Angular uses I lean towards adding a note in the docs, that you shouldn't deep-watch objects that are or contain |
@sbespaly I also agree If this bug closes as a
But it might fail depending on your data, see #12653. If you don't need deep copy you can also use extend:
It works fine with File objects and is more robust than It's also a workarround, but if you're still bothered with the overhead of converting File objects to Blob I think this is a bit less hacky. |
Actually I need deep copy, that's why I use angular.copy() function. |
Closes angular#5085 Closes angular#13193 Closes angular#14352 Closes angular#15904 Closes angular#16055 Closes angular#16061 Closes angular#16067
Closes angular#5085 Closes angular#13193 Closes angular#14352 Closes angular#15904 Closes angular#16055 Closes angular#16061 Closes angular#16067
Closes angular#5085 Closes angular#13193 Closes angular#14352 Closes angular#15904 Closes angular#16055 Closes angular#16061 Closes angular#16067
Closes angular#5085 Closes angular#13193 Closes angular#14352 Closes angular#15904 Closes angular#16055 Closes angular#16061 Closes angular#16067
Note: for support questions, please use one of these channels: https://github.com/angular/angular.js/blob/master/CONTRIBUTING.md#question. This repository's issues are reserved for feature requests and bug reports.
Do you want to request a feature or report a bug?
Bug
What is the current behavior?
angular.copy doesn't copy File object (part of file API) correctly. There was the same issue with Blob, but it was fixed.
If the current behavior is a bug, please provide the steps to reproduce and if possible a minimal demo of the problem via https://plnkr.co or similar (template: http://plnkr.co/edit/tpl:yBpEi4).
var file = new File([], "filename");
var file2 = angular.copy(file);
//variable 'file2' is not valid, and can not be used with file API anymore.
What is the expected behavior?
copy function should create valid copy of File object, like it was made for Blob
What is the motivation / use case for changing the behavior?
File object and Blob are very common objects, but for some reason copy function doesn't copy File object, but do this for Blob's. This lead to unclear behavior of copy function.
Which versions of Angular, and which browser / OS are affected by this issue? Did this work in previous versions of Angular? Please also test with the latest stable and snapshot (https://code.angularjs.org/snapshot/) versions.
1.5.3 release and latest sources on GitHub,
All browsers affected
Don't have implementation in previous versions
Other information (e.g. stacktraces, related issues, suggestions how to fix)
add copy code for File object in function
function copyType(source) in file Angular.js line:886
The text was updated successfully, but these errors were encountered: