diff --git a/.claude/settings.local.json b/.claude/settings.local.json index e52c49a..dc3909f 100644 --- a/.claude/settings.local.json +++ b/.claude/settings.local.json @@ -4,7 +4,9 @@ "Bash(git init:*)", "Bash(git add:*)", "Bash(git commit:*)", - "Bash(git remote add:*)" + "Bash(git remote add:*)", + "Bash(npm install:*)", + "Bash(npm run build:*)" ], "deny": [], "ask": [] diff --git a/main.ts b/main.ts index 5859d50..53c273a 100644 --- a/main.ts +++ b/main.ts @@ -28,14 +28,14 @@ export default class CounterPlugin extends Plugin { const walker = document.createTreeWalker(element, NodeFilter.SHOW_TEXT); const nodesToReplace: Array<{ node: Node; parent: Node }> = []; - let node; - while ((node = walker.nextNode())) { + let node: Node | null; + while ((node = walker.nextNode()) !== null) { const text = node.textContent || ''; const lines = text.split('\n'); lines.forEach((line, index) => { const match = line.match(counterRegex); - if (match) { + if (match && node) { nodesToReplace.push({ node, parent: node.parentNode! }); } });