Skip to content

Commit 710f3cb

Browse files
NullVoxPopuliclaude
andcommitted
fix: drop empty text nodes left behind by whitespace stripping
After strip flags trim surrounding whitespace, TextNodes whose chars become empty would still appear in the body as spurious append calls in the wire format. Remove them in a second pass after stripping. Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
1 parent 31df8ef commit 710f3cb

1 file changed

Lines changed: 8 additions & 0 deletions

File tree

packages/@glimmer/syntax/lib/parser/tokenizer-event-handlers.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -344,6 +344,14 @@ function stripBodyWhitespace(body: Stripable[]): void {
344344
}
345345
}
346346
}
347+
348+
// Drop any text nodes that are now empty after stripping.
349+
for (let i = body.length - 1; i >= 0; i--) {
350+
const stmt = body[i]!;
351+
if (stmt.type === 'TextNode' && stmt.chars === '') {
352+
body.splice(i, 1);
353+
}
354+
}
347355
}
348356

349357
function getOpenStrip(stmt: Stripable): boolean {

0 commit comments

Comments
 (0)