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

Copy doesn't work when model contains cyclic refs #39

Open
jri opened this issue Mar 22, 2017 · 0 comments
Open

Copy doesn't work when model contains cyclic refs #39

jri opened this issue Mar 22, 2017 · 0 comments

Comments

@jri
Copy link

jri commented Mar 22, 2017

On drop when copy is "on" a TypeError is thrown in case the source model contains cyclic references. (My model is a tree structure where the nodes have a "parent" reference.)

When vue-dragula builds the target model for the drop-model event it clones the source model by executing:

JSON.parse(JSON.stringify(sourceModel[dragIndex]))

The TypeError is thrown by JSON.stringify. By default JSON.stringify does not support cyclic references.

A solution would be if vue-dragula would offer an option to let the user configure the "replacer function" (resp. the whitelist array) to be passed as the 2nd argument to JSON.stringify.
https://developer.mozilla.org/en/docs/Web/JavaScript/Reference/Global_Objects/JSON/stringify

This way the user would get an opportunity to strip the problematic (= cyclic) model properties for stringification.

I'm using Vuejs 2 and vue-dragula 2.0.0-alpha.1 which worked fine until I added the cyclic model reference.

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

1 participant