Skip to content

fix: resolve #174 - fix regex for hyphenated tag names in HTML scanner#241

Merged
aeschli merged 2 commits into
microsoft:mainfrom
maruthang:fix/issue-174-vue-html-scan-error
Jul 13, 2026
Merged

fix: resolve #174 - fix regex for hyphenated tag names in HTML scanner#241
aeschli merged 2 commits into
microsoft:mainfrom
maruthang:fix/issue-174-vue-html-scan-error

Conversation

@maruthang

Copy link
Copy Markdown
Contributor

Summary

Fixes #174

Bug: Hyphenated custom element tag names (e.g., <s-c-feature>) were not scanned correctly, causing Vue HTML scan errors.

Root Cause: In nextElementName() in htmlScanner.ts, the regex character class [_:\w-.\d] placed the hyphen between \w and ., making it ambiguous (interpreted as a range rather than a literal hyphen).

Fix: Moved the hyphen to the end of the character class ([_:\w.\d-]) so it is unambiguously treated as a literal hyphen character.

Changes

  • src/parser/htmlScanner.ts: Fixed regex in nextElementName() — moved hyphen to end of character class
  • src/test/scanner.test.ts: Added 3 regression tests for hyphenated tag names (Vue custom element, self-closing, and with attributes)

Testing

  • Added regression tests in src/test/scanner.test.ts that verify correct tokenization of hyphenated element names like s-c-feature, my-component, and el-button
  • All 101 existing tests pass

@aeschli
aeschli enabled auto-merge (squash) July 12, 2026 19:42
@aeschli
aeschli merged commit 775302f into microsoft:main Jul 13, 2026
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

vue html scan error

4 participants