Skip to content

Commit

Permalink
Fill the holes of the sparse array with undefined
Browse files Browse the repository at this point in the history
  • Loading branch information
genki committed Oct 20, 2023
1 parent bfe8040 commit 8acef35
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions packages/qwik/src/core/state/common.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { assertFail, assertTrue } from '../error/assert';
import { qError, QError_verifySerializable } from '../error/error';
import { isNode } from '../util/element';
import { seal } from '../util/qdev';
import { isArray, isFunction, isObject, isSerializableObject } from '../util/types';
Expand Down Expand Up @@ -64,7 +63,10 @@ const _verifySerializable = <T>(value: T, seen: Set<any>, ctx: string, preMessag
// Make sure the array has no holes
unwrapped.forEach((v, i) => {
if (i !== expectIndex) {
throw qError(QError_verifySerializable, unwrapped);
const array = value as any[];
for (let j = expectIndex; j < i; j++) {
array[j] = undefined;
}
}
_verifySerializable(v, seen, ctx + '[' + i + ']');
expectIndex = i + 1;
Expand Down

0 comments on commit 8acef35

Please sign in to comment.