Closed Eldresh closed 4 months ago
Thanks for reporting, I can consistently reproduce the issue the way you describe it, like:
function query (data) {
return data.splice(2)
}
The reason is that the splice
method mutates the original array. In the query the data
variable points to the real data, and if you alter it, it is changed for real. The same happens for example if you do say array[0] = null
inside the query, tha will clear the first item.
To solve this, we'll have to make sure you can't accidentally mutate the oringial data
. Maybe we can use Mutative there somehow. Or maybe I can wrap the data
in some readonly proxy, let me give that a try.
This looks like a promising approach: https://github.com/kourge/readonly-proxy
I tried out readonly-proxy
but ran into some issues. Solved now via 337f812 (not yet published)
Fixed now in svelte-jsoneditor@0.21.5
and JSON Editor Online v6.15.1
. Can you give it a try @Eldresh?
Fixed now in
svelte-jsoneditor@0.21.5
and JSON Editor Onlinev6.15.1
. Can you give it a try @Eldresh?
Yup. Now it gives me TypeError: unable to delete property, which is much better than accidentally losing everything.
👍
I cannot begin to tell you how much I wish I could consistently reproduce this error, but its reasonably consistent when you make an error typing in a function. A good example (in my experience) is typing
.splice(2)
and then deleting it, which will leave you with 2 things in your array or an empty array without ever once hitting 'transform' and without the ability to undo it, resulting in a loss of data.I am using the website, https://jsoneditoronline.org/, and encounter this unfortunately quite often.
Browser: Chrome 120.0.6099.217 (Official Build) (64-bit)