Description
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.