fix(parse/html): don't lex "use" as USE_KW when in html text content#9151
fix(parse/html): don't lex "use" as USE_KW when in html text content#9151
USE_KW when in html text content#9151Conversation
🦋 Changeset detectedLatest commit: 0cabd62 The changes in this PR will be included in the next version bump. This PR includes changesets to release 13 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
|
|
||
| // #region Check functions | ||
|
|
||
| const SVELTE_KEYWORDS: TokenSet<HtmlSyntaxKind> = token_set!( |
There was a problem hiding this comment.
I would rename this, because now it doesn't contain all Svelte keywords
There was a problem hiding this comment.
It does because of the .union
cc891a3 to
bf0f5a8
Compare
4027bb2 to
5ef8c9a
Compare
d24c2d1 to
5f1fdb5
Compare
5ef8c9a to
5f731a2
Compare
5f731a2 to
cb3acb7
Compare
cb3acb7 to
0cabd62
Compare
|
No actionable comments were generated in the recent review. 🎉 WalkthroughThis patch fixes incorrect parsing of Svelte directive keywords when they appear as plain text content in HTML/Svelte files. The change modifies the SVELTE\_KEYWORDS constant to include directive keywords (use, style, bind, transition, in, out, class, animate) via union with SVELTE\_DIRECTIVE\_KEYWORDS. This ensures plain text like "use JavaScript" is correctly treated as text content rather than triggering directive parsing. Test files verify the fix handles keyword directives rendered as text within span and paragraph elements. Possibly related PRs
Suggested reviewers
🚥 Pre-merge checks | ✅ 2✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches
🧪 Generate unit tests (beta)
Tip Issue Planner is now in beta. Read the docs and try it out! Share your feedback on Discord. Comment |
Merging this PR will not alter performance
Comparing Footnotes
|

Summary
Previously, the HTML lexer emitted keyword tokens (e.g.
USE_KW,STYLE_KW) when those words appear as plain text content between HTML tags. The parser has a guard (is_at_svelte_keyword) that re-lexes keyword tokens asHtmlTextwhen they appear in a text-content position, butT![use]andT![style]were missing from that guard.planned by sonnet 4.6 and tests generated by kimi k2.5
Test Plan
added snapshot tests
Docs