mirror of
https://github.com/mealie-recipes/mealie.git
synced 2025-08-04 21:15:22 +02:00
fix: JSON Editor Breaks On Invalid JSON (#5814)
Co-authored-by: Kuchenpirat <24235032+Kuchenpirat@users.noreply.github.com>
This commit is contained in:
parent
14b3fd524f
commit
d7191983bd
2 changed files with 9 additions and 6 deletions
|
@ -26,10 +26,10 @@ export default defineComponent({
|
|||
},
|
||||
},
|
||||
emits: ["update:modelValue"],
|
||||
setup(_, { emit }) {
|
||||
setup(props, { emit }) {
|
||||
function parseEvent(event: any): object {
|
||||
if (!event) {
|
||||
return {};
|
||||
return props.modelValue || {};
|
||||
}
|
||||
try {
|
||||
if (event.json) {
|
||||
|
@ -43,11 +43,14 @@ export default defineComponent({
|
|||
}
|
||||
}
|
||||
catch {
|
||||
return {};
|
||||
return props.modelValue || {};
|
||||
}
|
||||
}
|
||||
function onChange(event: any) {
|
||||
emit("update:modelValue", parseEvent(event));
|
||||
const parsed = parseEvent(event);
|
||||
if (parsed !== props.modelValue) {
|
||||
emit("update:modelValue", parsed);
|
||||
}
|
||||
}
|
||||
return {
|
||||
onChange,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue