diff --git a/packages/qwik/src/core/container/pause.ts b/packages/qwik/src/core/container/pause.ts index 58171ec42ff..746c57fad67 100644 --- a/packages/qwik/src/core/container/pause.ts +++ b/packages/qwik/src/core/container/pause.ts @@ -28,7 +28,12 @@ import { import { isArray, isObject, isSerializableObject } from '../util/types'; import { directGetAttribute, directSetAttribute } from '../render/fast-calls'; import { isNotNullable, isPromise } from '../util/promises'; -import { collectDeps, serializeValue, UNDEFINED_PREFIX } from './serializers'; +import { + collectDeps, + serializeValue, + UNDEFINED_PREFIX, + NOSERIALIZE_PREFIX, +} from './serializers'; import { type ContainerState, FILTER_REJECT, @@ -139,6 +144,7 @@ export const _serializeData = async (data: any, pureQRL?: boolean) => { } return obj; case 'string': + return NOSERIALIZE_PREFIX + obj; case 'boolean': return obj; } @@ -482,6 +488,7 @@ export const _pauseFromContexts = async ( } return obj; case 'string': + return NOSERIALIZE_PREFIX + obj; case 'boolean': return obj; } diff --git a/packages/qwik/src/core/container/resume.ts b/packages/qwik/src/core/container/resume.ts index e25cdd43eb2..c1b335f2b0f 100644 --- a/packages/qwik/src/core/container/resume.ts +++ b/packages/qwik/src/core/container/resume.ts @@ -8,7 +8,13 @@ import { emitEvent } from '../util/event'; import { isArray, isSerializableObject, isString } from '../util/types'; import { directGetAttribute, directSetAttribute } from '../render/fast-calls'; -import { createParser, OBJECT_TRANSFORMS, type Parser, UNDEFINED_PREFIX } from './serializers'; +import { + createParser, + OBJECT_TRANSFORMS, + type Parser, + UNDEFINED_PREFIX, + NOSERIALIZE_PREFIX, +} from './serializers'; import { type ContainerState, _getContainerState, @@ -76,7 +82,9 @@ export const _deserializeData = (data: string, element?: unknown) => { for (let i = 0; i < _objs.length; i++) { const value = _objs[i]; if (isString(value)) { - _objs[i] = value === UNDEFINED_PREFIX ? undefined : parser.prepare(value); + _objs[i] = value === UNDEFINED_PREFIX ? undefined : + value.startsWith(NOSERIALIZE_PREFIX) ? value.slice(1) : + parser.prepare(value); } } @@ -228,7 +236,9 @@ export const resumeContainer = (containerEl: Element) => { assertTrue(objs.length > index, 'resume: index is out of bounds', id); let value = objs[index]; if (isString(value)) { - value = value === UNDEFINED_PREFIX ? undefined : parser.prepare(value); + value = value === UNDEFINED_PREFIX ? undefined : + value.startsWith(NOSERIALIZE_PREFIX) ? value.slice(1) : + parser.prepare(value); } let obj = value; for (let i = id.length - 1; i >= 0; i--) { diff --git a/packages/qwik/src/core/container/serializers.ts b/packages/qwik/src/core/container/serializers.ts index 19360f1b38f..fc5077abc91 100644 --- a/packages/qwik/src/core/container/serializers.ts +++ b/packages/qwik/src/core/container/serializers.ts @@ -49,7 +49,8 @@ import { Slot } from '../render/jsx/slot.public'; \': single quote (U+0027 APOSTROPHE) \\: backslash (U+005C REVERSE SOLIDUS) */ -export const UNDEFINED_PREFIX = '\u0001'; +export const NOSERIALIZE_PREFIX = '\u0000'; +export const UNDEFINED_PREFIX = '\u0001'; export interface Serializer { $prefix$: string;