Skip to content

Commit

Permalink
fix(core): serialize the 'key' attribute of JSX nodes (#5501)
Browse files Browse the repository at this point in the history
Adds serialization and deserialization of the 'key' attribute, the only member of JSXNodeImpl which
was not serialized thus far.

Issue #5496
  • Loading branch information
yanivhamo committed Jan 18, 2024
1 parent 743f7a6 commit bba73dc
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions packages/qwik/src/core/container/serializers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -390,6 +390,7 @@ const JSXNodeSerializer = /*#__PURE__*/ serializer<JSXNode>({
collectValue(node.children, collector, leaks);
collectValue(node.props, collector, leaks);
collectValue(node.immutableProps, collector, leaks);
collectValue(node.key, collector, leaks);
let type = node.type;
if (type === Slot) {
type = ':slot';
Expand All @@ -406,24 +407,26 @@ const JSXNodeSerializer = /*#__PURE__*/ serializer<JSXNode>({
type = ':fragment';
}
return `${getObjID(type)} ${getObjID(node.props)} ${getObjID(node.immutableProps)} ${getObjID(
node.children
)} ${node.flags}`;
node.key
)} ${getObjID(node.children)} ${node.flags}`;
},
$prepare$: (data) => {
const [type, props, immutableProps, children, flags] = data.split(' ');
const [type, props, immutableProps, key, children, flags] = data.split(' ');
const node = new JSXNodeImpl(
type as string,
props as any,
immutableProps as any,
children,
parseInt(flags, 10)
parseInt(flags, 10),
key as string
);
return node;
},
$fill$: (node, getObject) => {
node.type = getResolveJSXType(getObject(node.type as string));
node.props = getObject(node.props as any as string);
node.immutableProps = getObject(node.immutableProps as any as string);
node.key = getObject(node.key as string);
node.children = getObject(node.children as string);
},
});
Expand Down

0 comments on commit bba73dc

Please sign in to comment.