Skip to content

Commit de5a37e

Browse files
committed
changing lastParsedData property to hold an entirely new object, which is cloned from the new value of parsedData, so that the comparison of newValue to lastParsedData would return false, in case user edits the json object with the provided editor.
Otherwise lastParsedData would be holding an reference to parsedData object, and when parsedData changes lastParsedData would automatically reflect those changes which always return before emitting input event from the watcher on parsedData property
1 parent 81fe9b7 commit de5a37e

File tree

3 files changed

+9
-2
lines changed

3 files changed

+9
-2
lines changed

package-lock.json

Lines changed: 6 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@
4444
},
4545
"dependencies": {
4646
"highlight.js": "^9.15.6",
47+
"lodash.clonedeep": "^4.5.0",
4748
"vue": "^2.6.8",
4849
"vuedraggable": "^2.23.2"
4950
},

src/JsonEditor.vue

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66

77
<script>
88
import JsonView from "./JsonView.vue";
9+
import cloneDeep from "lodash.clonedeep";
910
1011
export default {
1112
name: "JsonEditor",
@@ -50,7 +51,7 @@ export default {
5051
return;
5152
}
5253
53-
this.lastParsedData = newValue;
54+
this.lastParsedData = cloneDeep(newValue);
5455
this.$emit("input", this.makeJson(this.parsedData));
5556
},
5657
deep: true

0 commit comments

Comments
 (0)