Skip to content

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

Open
maruthang wants to merge 1 commit into
microsoft:mainfrom
maruthang:fix/issue-174-vue-html-scan-error
Open

fix: resolve #174 - fix regex for hyphenated tag names in HTML scanner#241
maruthang wants to merge 1 commit 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

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

1 participant