Skip to content

Commit 8cb5ab9

Browse files
fix: ignore comments while comparing nodes in node_match
1 parent effeb7a commit 8cb5ab9

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

packages/svelte/src/compiler/compile/render_dom/invalidate.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ export function invalidate(renderer, scope, node, names, main_execution_context
5050
if (
5151
node.type === 'AssignmentExpression' &&
5252
node.operator === '=' &&
53-
nodes_match(node.left, node.right) &&
53+
nodes_match(node.left, node.right, ["trailingComments","leadingComments"]) &&
5454
tail.length === 0
5555
) {
5656
return get_invalidated(head, node);

packages/svelte/src/compiler/utils/nodes_match.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
export function nodes_match(a, b) {
1+
export function nodes_match(a, b, ignoreKeys=[]) {
22
if (!!a !== !!b) return false;
33
if (Array.isArray(a) !== Array.isArray(b)) return false;
44

@@ -8,8 +8,8 @@ export function nodes_match(a, b) {
88
return a.every((child, i) => nodes_match(child, b[i]));
99
}
1010

11-
const a_keys = Object.keys(a).sort();
12-
const b_keys = Object.keys(b).sort();
11+
const a_keys = Object.keys(a).sort().filter(key => !ignoreKeys.includes(key));
12+
const b_keys = Object.keys(b).sort().filter(key => !ignoreKeys.includes(key));
1313

1414
if (a_keys.length !== b_keys.length) return false;
1515

0 commit comments

Comments
 (0)