You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
fix(html): keep a dynamic tag's attribute name from opening raw text mode - #4152
In @solidjs/html, a dynamic tag whose first attribute is named like a raw text element fails to parse:
html`<${Link}title="Home"><b>Home</b></${Link}>`;// Error: Unclosed tag for <0>
The tokenizer records the first identifier it sees inside a tag as the tag name. A dynamic tag's name is an expression, so the first attribute name (title, style, script, textarea, noscript) takes its place. On >, the tokenizer enters raw text mode and looks for </title>, so the children and the </${Link}> closing tag are read as text.
This change records the tag name only for the identifier directly after <.
How did you test this change?
Added a test to packages/html/test/tokenize.test.ts and one to packages/html/test/parse.test.ts. Both fail before the fix and pass after it.
In packages/html:
npx vitest run test/tokenize.test.ts test/parse.test.ts without the fix: 2 failed, 123 passed.
Same command with the fix: 125 passed.
npx vitest run after pnpm build: 4 files, 208 tests passed.
⚠️3 benchmarks spent significant time in system calls
System calls cannot be consistently instrumented, so they are not included in the measure, which understates the real cost. Please switch to the Walltime instrument to accurately measure system calls.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
In
@solidjs/html, a dynamic tag whose first attribute is named like a raw text element fails to parse:The tokenizer records the first identifier it sees inside a tag as the tag name. A dynamic tag's name is an expression, so the first attribute name (
title,style,script,textarea,noscript) takes its place. On>, the tokenizer enters raw text mode and looks for</title>, so the children and the</${Link}>closing tag are read as text.This change records the tag name only for the identifier directly after
<.How did you test this change?
Added a test to
packages/html/test/tokenize.test.tsand one topackages/html/test/parse.test.ts. Both fail before the fix and pass after it.In
packages/html:npx vitest run test/tokenize.test.ts test/parse.test.tswithout the fix: 2 failed, 123 passed.npx vitest runafterpnpm build: 4 files, 208 tests passed.npx prettier --checkon the changed files: clean.Fixes #4151