Skip to content

Commit 5bcfe48

Browse files
committed
chore: code optimization
1 parent a12a128 commit 5bcfe48

File tree

1 file changed

+2
-6
lines changed

1 file changed

+2
-6
lines changed

src/Component.ts

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -105,9 +105,7 @@ export default defineComponent({
105105
onChangeMode,
106106
mode: initialMode,
107107
...(initialValue !== undefined && {
108-
content: typeof initialValue === 'string'
109-
? { text: initialValue }
110-
: { json: initialValue },
108+
content: { [typeof initialValue === 'string' ? 'text' : 'json']: initialValue },
111109
}),
112110
},
113111
],
@@ -138,9 +136,7 @@ export default defineComponent({
138136
jsonEditor.value.set(
139137
[undefined, ''].includes(newModelValue)
140138
? { text: '' }
141-
: typeof newModelValue === 'string'
142-
? { text: newModelValue }
143-
: { json: newModelValue },
139+
: { [typeof newModelValue === 'string' ? 'text' : 'json']: newModelValue },
144140
)
145141
}
146142
},

0 commit comments

Comments
 (0)