Skip to content

Commit be5dfdc

Browse files
committed
feat(cursors): fix diff props
1 parent 97501fe commit be5dfdc

File tree

3 files changed

+20
-16
lines changed

3 files changed

+20
-16
lines changed

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

Lines changed: 18 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import { isDev } from '@qwik.dev/core/build';
2-
import { _CONST_PROPS, _EFFECT_BACK_REF, _VAR_PROPS } from '../internal';
32
import { clearAllEffects, clearEffectSubscription } from '../reactive-primitives/cleanup';
43
import { WrappedSignalImpl } from '../reactive-primitives/impl/wrapped-signal-impl';
54
import type { Signal } from '../reactive-primitives/signal.public';
@@ -31,7 +30,7 @@ import type { QRL } from '../shared/qrl/qrl.public';
3130
import type { HostElement, QElement, QwikLoaderEventScope, qWindow } from '../shared/types';
3231
import { DEBUG_TYPE, QContainerValue, VirtualType } from '../shared/types';
3332
import { escapeHTML } from '../shared/utils/character-escaping';
34-
import { _OWNER, _PROPS_HANDLER } from '../shared/utils/constants';
33+
import { _CONST_PROPS, _OWNER, _PROPS_HANDLER, _VAR_PROPS } from '../shared/utils/constants';
3534
import {
3635
fromCamelToKebabCase,
3736
getEventDataFromHtmlAttribute,
@@ -97,6 +96,7 @@ import type { VirtualVNode } from '../shared/vnode/virtual-vnode';
9796
import type { TextVNode } from '../shared/vnode/text-vnode';
9897
import { markVNodeDirty } from '../shared/vnode/vnode-dirty';
9998
import { ChoreBits } from '../shared/vnode/enums/chore-bits.enum';
99+
import { _EFFECT_BACK_REF } from '../reactive-primitives/backref';
100100

101101
export const vnode_diff = (
102102
container: ClientContainer,
@@ -819,8 +819,8 @@ export const vnode_diff = (
819819

820820
function diffProps(
821821
vnode: ElementVNode,
822-
srcAttrs: Record<string, any>,
823-
dstAttrs: Record<string, any>,
822+
newAttrs: Record<string, any>,
823+
oldAttrs: Record<string, any>,
824824
currentFile: string | null
825825
): boolean {
826826
vnode_ensureElementInflated(vnode);
@@ -904,21 +904,27 @@ export const vnode_diff = (
904904
};
905905

906906
// Actual diffing logic
907-
for (const key in srcAttrs) {
908-
const srcValue = srcAttrs[key];
907+
// Apply all new attributes
908+
for (const key in newAttrs) {
909+
const newValue = newAttrs[key];
909910
const isEvent = isHtmlAttributeAnEventName(key);
910911

911-
if (key in dstAttrs) {
912-
if (srcValue !== dstAttrs[key]) {
913-
isEvent ? recordJsxEvent(key, srcValue) : record(key, srcValue);
912+
if (key in oldAttrs) {
913+
if (newValue !== oldAttrs[key]) {
914+
isEvent ? recordJsxEvent(key, newValue) : record(key, newValue);
914915
}
915916
} else {
916-
isEvent ? recordJsxEvent(key, srcValue) : record(key, srcValue);
917+
isEvent ? recordJsxEvent(key, newValue) : record(key, newValue);
917918
}
918919
}
919920

920-
for (const key in dstAttrs) {
921-
if (!(key in srcAttrs) && !isHtmlAttributeAnEventName(key)) {
921+
// Remove attributes that no longer exist in new props
922+
for (const key in oldAttrs) {
923+
if (
924+
!(key in newAttrs) &&
925+
!key.startsWith(HANDLER_PREFIX) &&
926+
!isHtmlAttributeAnEventName(key)
927+
) {
922928
record(key, null);
923929
}
924930
}

packages/qwik/src/core/shared/cursor/cursor-flush.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,8 @@ function flushChanges(
9191
}
9292
}
9393
}
94+
vNode.operation = null;
95+
vNode.dirty &= ~ChoreBits.OPERATION;
9496
}
9597
}
9698

packages/qwik/src/core/shared/cursor/cursor-walker.ts

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -65,11 +65,8 @@ export function processCursorQueue(
6565
): void {
6666
isNextTickScheduled = false;
6767

68-
console.log('processCursorQueue');
69-
7068
let cursor: Cursor | null = null;
7169
while ((cursor = getHighestPriorityCursor())) {
72-
console.log('while loop');
7370
walkCursor(cursor, options);
7471
if (!(cursor.dirty & ChoreBits.DIRTY_MASK)) {
7572
removeCursorFromQueue(cursor);
@@ -164,7 +161,6 @@ export function walkCursor(cursor: Cursor, options: WalkOptions): void {
164161
}
165162

166163
let result: ValueOrPromise<void> | undefined;
167-
console.log('executeChoreSequence', currentVNode.dirty);
168164
// Execute chores in order
169165
if (currentVNode.dirty & ChoreBits.TASKS) {
170166
result = executeTasks(currentVNode, container, cursor);

0 commit comments

Comments
 (0)