From a731f245fe7e284727e41b701b9fa1b386c50eec Mon Sep 17 00:00:00 2001 From: Nguyen Tran Date: Tue, 28 Feb 2023 09:49:40 -0500 Subject: [PATCH] Add comment on how extract_ignores_above_node works --- src/compiler/utils/extract_svelte_ignore.ts | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/compiler/utils/extract_svelte_ignore.ts b/src/compiler/utils/extract_svelte_ignore.ts index 3e98c51771..f744199457 100644 --- a/src/compiler/utils/extract_svelte_ignore.ts +++ b/src/compiler/utils/extract_svelte_ignore.ts @@ -36,8 +36,12 @@ export function extract_ignores_above_position(position: number, template_nodes: return []; } -export function extract_ignores_above_node(node: Node): string[] { - // We traverse along nodes on the same array as the node we pass in +export function extract_ignores_above_node(node: INode): string[] { + /** + * This utilizes the fact that node has a prev and a next attribute + * which means that it can find svelte-ignores along + * the nodes on the same level as itself who share the same parent. + */ let cur_node: INode | undefined = node.prev; while (cur_node) { if (cur_node.type !== 'Comment' && cur_node.type !== 'Text') {