Skip to content

Commit 2bf93fc

Browse files
committed
refactor: don't create subscription data for every property
1 parent f1c86e1 commit 2bf93fc

File tree

1 file changed

+11
-21
lines changed

1 file changed

+11
-21
lines changed

packages/qwik/src/core/client/vnode-diff.ts

Lines changed: 11 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -156,17 +156,15 @@ export const vnode_diff = (
156156
// When we descend into children, we need to skip advance() because we just descended.
157157
let shouldAdvance = true;
158158

159-
/**
160-
* When we are rendering inside a projection we don't want to process child components. Child
161-
* components will be processed only if the projection is re-projected with a `<Slot>`.
162-
*
163-
* Example: <Parent> <div> <Child/> </div> </Parent>
164-
*
165-
* In the above example, the `Child` component will not be processed because it is inside a
166-
* projection. Only if the `<Parent>` projects its content with `<Slot>` will the `Child`
167-
* component be processed.
168-
*/
169-
// let inContentProjection = false;
159+
const CONST_SUBSCRIPTION_DATA = new SubscriptionData({
160+
$scopedStyleIdPrefix$: scopedStyleIdPrefix,
161+
$isConst$: true,
162+
});
163+
164+
const NON_CONST_SUBSCRIPTION_DATA = new SubscriptionData({
165+
$scopedStyleIdPrefix$: scopedStyleIdPrefix,
166+
$isConst$: false,
167+
});
170168
////////////////////////////////
171169

172170
diff(jsxNode, vStartNode);
@@ -648,16 +646,12 @@ export const vnode_diff = (
648646
}
649647

650648
if (isSignal(value)) {
651-
const signalData = new SubscriptionData({
652-
$scopedStyleIdPrefix$: scopedStyleIdPrefix,
653-
$isConst$: true,
654-
});
655649
value = trackSignalAndAssignHost(
656650
value as Signal<unknown>,
657651
vNewNode as ElementVNode,
658652
key,
659653
container,
660-
signalData
654+
CONST_SUBSCRIPTION_DATA
661655
);
662656
}
663657

@@ -838,11 +832,7 @@ export const vnode_diff = (
838832
}
839833

840834
if (isSignal(value)) {
841-
const signalData = new SubscriptionData({
842-
$scopedStyleIdPrefix$: scopedStyleIdPrefix,
843-
$isConst$: false,
844-
});
845-
value = trackSignalAndAssignHost(value, vnode, key, container, signalData);
835+
value = trackSignalAndAssignHost(value, vnode, key, container, NON_CONST_SUBSCRIPTION_DATA);
846836
}
847837

848838
vnode_setAttr(

0 commit comments

Comments
 (0)