Skip to content
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

cloning File objects #92

Open
art-in opened this issue Mar 12, 2018 · 6 comments
Open

cloning File objects #92

art-in opened this issue Mar 12, 2018 · 6 comments

Comments

@art-in
Copy link

art-in commented Mar 12, 2018

  1. Take File object from <input type='file'>
  2. Try to clone
TypeError: Cannot assign to read only property 'size' of object '#<File>'
    at _clone (clone.js:156)
    at _clone (clone.js:156)
    at _clone (clone.js:156)
    at _clone (clone.js:156)
    at _clone (clone.js:156)
    at _clone (clone.js:156)
    at clone (clone.js:196)
    at LogEntry.set (LogEntry.js:148)
@art-in
Copy link
Author

art-in commented Mar 12, 2018

Is there any workaround for this? Eg. would be neat to ignore properties with certain names while deep cloning.

@pvorb
Copy link
Owner

pvorb commented Mar 22, 2018

Unfortunately I'm not aware of any workarounds for this behaviour. I'd argue that it's better to throw an exception in that case than silently ignore it and have no proper clone of the object, don't you think?

@art-in
Copy link
Author

art-in commented Mar 23, 2018

@pvorb I'm thinking about optional ignoreUnclonableObjects flag (default: false).

Here is the case:
I have deep objects tree which consists of 99% clonable objects, except one of deep objects is HtmlElement and another one is File. Right now to clone whole structure I have to nullify those props in source object before cloning, and then restore back after cloning.

Having ability to ignore or shallow copy unclonable objects right in clone would save me from that awkward nullify-restore code.

@pvorb
Copy link
Owner

pvorb commented Mar 23, 2018

Okay, that's a use case.

@RaulTsc
Copy link

RaulTsc commented Aug 6, 2018

Any plan to support cloning Blobs/Files? https://github.com/jonschlinkert/clone-deep seems to do it, but they use for (const in which breaks on IE11 ..

@pvorb
Copy link
Owner

pvorb commented Aug 9, 2018

No

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants