Skip to content

Commit 918a126

Browse files
committedJan 19, 2024
fix: #391 editor not supporting Object.create(null) as object
1 parent 2dc62f0 commit 918a126

File tree

3 files changed

+18
-12
lines changed

3 files changed

+18
-12
lines changed
 

‎package-lock.json

+8-8
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎package.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@
9090
"ajv": "^8.12.0",
9191
"codemirror-wrapped-line-indent": "^1.0.0",
9292
"diff-sequences": "^29.6.3",
93-
"immutable-json-patch": "6.0.0",
93+
"immutable-json-patch": "6.0.1",
9494
"jmespath": "^0.16.0",
9595
"json-source-map": "^0.6.1",
9696
"jsonrepair": "^3.5.1",
@@ -147,7 +147,7 @@
147147
"svelte-check": "3.6.3",
148148
"svelte-preprocess": "5.1.3",
149149
"typescript": "5.3.3",
150-
"vite": "5.0.11",
150+
"vite": "5.0.12",
151151
"vitest": "1.2.1"
152152
}
153153
}

‎src/lib/utils/typeUtils.ts

+8-2
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,11 @@ import type { JSONParser } from '../types.js'
99
export function isObject(value: unknown): value is Record<string, unknown> {
1010
// note that we check constructor.name, not constructor === Object,
1111
// so we can use objects created in a different JS realm like an iframe.
12-
return typeof value === 'object' && value !== null && value.constructor.name === 'Object'
12+
return (
13+
typeof value === 'object' &&
14+
value !== null &&
15+
(value.constructor === undefined || value.constructor.name === 'Object')
16+
)
1317
}
1418

1519
/**
@@ -22,7 +26,9 @@ export function isObjectOrArray(value: unknown): value is Object | Array<unknown
2226
return (
2327
typeof value === 'object' &&
2428
value !== null &&
25-
(value.constructor.name === 'Object' || value.constructor.name === 'Array')
29+
(value.constructor === undefined ||
30+
value.constructor.name === 'Object' ||
31+
value.constructor.name === 'Array')
2632
)
2733
}
2834

0 commit comments

Comments
 (0)
Please sign in to comment.