Skip to content

Commit 10e62a9

Browse files
committed
fix: jsonEditor.value could be undefined under some certain conditions in Vue 2.6 & 2.7
1 parent 29fb1e1 commit 10e62a9

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

src/Component.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,7 @@ export default defineComponent({
144144
watch(
145145
() => props.mode,
146146
(mode) => {
147-
// `jsonEditor.value` could be `undefined` in Vue 2.6 (dev environment)
147+
// `jsonEditor.value` could be `undefined` in Vue 2.6
148148
jsonEditor.value?.updateProps({
149149
mode,
150150
})
@@ -154,7 +154,7 @@ export default defineComponent({
154154
watch(
155155
() => Array.from(boolAttrs, boolAttr => props[boolAttr]),
156156
(values) => {
157-
jsonEditor.value.updateProps(
157+
jsonEditor.value?.updateProps(
158158
Object.fromEntries(Array.from(values, (v, i) => [boolAttrs[i], v]).filter(([, v]) => v !== undefined)),
159159
)
160160
},
@@ -174,7 +174,7 @@ export default defineComponent({
174174
if (newAttrs.onChangeMode) {
175175
defaultFunctionAttrs.onChangeMode = onChangeMode
176176
}
177-
jsonEditor.value.updateProps(
177+
jsonEditor.value?.updateProps(
178178
Object.getOwnPropertyNames(defaultFunctionAttrs).length > 0
179179
? conclude([newAttrs, defaultFunctionAttrs], {
180180
type: Object,

0 commit comments

Comments
 (0)