Skip to content

Commit 7d4b46a

Browse files
apply suggestion
1 parent 50cecc0 commit 7d4b46a

1 file changed

Lines changed: 4 additions & 4 deletions

File tree

packages/kit/src/runtime/form-utils.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -466,14 +466,14 @@ export function deep_set(object, keys, value) {
466466
check_prototype_pollution(key);
467467

468468
const is_array = /^\d+$/.test(keys[i + 1]);
469-
const exists = Object.hasOwn(current, key);
470-
const inner = current[key];
469+
const inner = Object.hasOwn(current, key) ? current[key] : undefined;
470+
const exists = inner != null;
471471

472-
if (exists && inner != null && is_array !== Array.isArray(inner)) {
472+
if (exists && is_array !== Array.isArray(inner)) {
473473
throw new Error(`Invalid array key ${keys[i + 1]}`);
474474
}
475475

476-
if (!exists || inner == null) {
476+
if (!exists) {
477477
current[key] = is_array ? [] : {};
478478
}
479479

0 commit comments

Comments
 (0)