Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit f8eed63

Browse filesBrowse files
authored
fix(StateEditor): add isPrimitive helper and support bigint type (#744) (#854)
1 parent 09002d2 commit f8eed63
Copy full SHA for f8eed63

File tree

1 file changed

+8
-5
lines changed
Filter options

1 file changed

+8
-5
lines changed

‎packages/devtools/client/components/StateEditor.vue

Copy file name to clipboardExpand all lines: packages/devtools/client/components/StateEditor.vue
+8-5Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,13 +22,16 @@ const colorMode = getColorMode()
2222
const proxy = shallowRef()
2323
const error = shallowRef()
2424
25+
function isPrimitive(value: any): boolean {
26+
return ['number', 'bigint', 'string', 'boolean'].includes(typeof value)
27+
}
28+
2529
function clone() {
2630
error.value = undefined
2731
try {
28-
if (props.state)
29-
proxy.value = JSON.parse(JSON.stringify(props.state || {}))
30-
else if (typeof props.state === 'number' || typeof props.state !== 'string')
31-
proxy.value = props.state
32+
proxy.value = isPrimitive(props.state)
33+
? props.state
34+
: JSON.parse(JSON.stringify(props.state || {}))
3235
}
3336
catch (e) {
3437
console.error(e)
@@ -44,7 +47,7 @@ onMounted(() => {
4447
watch(
4548
() => [props.revision, props.state],
4649
([_, state]) => {
47-
if (typeof state !== 'number' && typeof state !== 'string')
50+
if (!isPrimitive(state))
4851
deepSync(state, props.state)
4952
else
5053
proxy.value = props.state

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.