Skip to content

feat(html_parser): add name reference identifier#8827

Closed
Netail wants to merge 1 commit intobiomejs:nextfrom
Netail:feat/name-reference-identifier
Closed

feat(html_parser): add name reference identifier#8827
Netail wants to merge 1 commit intobiomejs:nextfrom
Netail:feat/name-reference-identifier

Conversation

@Netail
Copy link
Member

@Netail Netail commented Jan 21, 2026

Summary

Add support for the name of an element being a reference identifier (hopefully into the right direction?)

Test Plan

Docs

@changeset-bot
Copy link

changeset-bot bot commented Jan 21, 2026

🦋 Changeset detected

Latest commit: 0befd10

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 15 packages
Name Type
@biomejs/biome Minor
@biomejs/cli-win32-x64 Minor
@biomejs/cli-win32-arm64 Minor
@biomejs/cli-darwin-x64 Minor
@biomejs/cli-darwin-arm64 Minor
@biomejs/cli-linux-x64 Minor
@biomejs/cli-linux-arm64 Minor
@biomejs/cli-linux-x64-musl Minor
@biomejs/cli-linux-arm64-musl Minor
@biomejs/wasm-web Minor
@biomejs/wasm-bundler Minor
@biomejs/wasm-nodejs Minor
@biomejs/backend-jsonrpc Patch
@biomejs/js-api Major
@biomejs/prettier-compare Patch

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

@github-actions github-actions bot added A-Linter Area: linter A-Parser Area: parser A-Formatter Area: formatter A-Tooling Area: internal tools L-HTML Language: HTML and super languages labels Jan 21, 2026
@Netail Netail changed the title feat(lsp): report progress while scanning the project (#7961) feat(html_parser): add name reference identifier Jan 21, 2026
@codspeed-hq
Copy link

codspeed-hq bot commented Jan 21, 2026

Merging this PR will not alter performance

✅ 3 untouched benchmarks
🆕 1 new benchmark
⏩ 152 skipped benchmarks1

Performance Changes

Benchmark BASE HEAD Efficiency
🆕 html_analyzer[index_1033418810622582172.html] N/A 398.9 µs N/A

Comparing Netail:feat/name-reference-identifier (0befd10) with next (cb112ce)

Open in CodSpeed

Footnotes

  1. 152 benchmarks were skipped, so the baseline results were used instead. If they were deleted from the codebase, click here and archive them to remove them from the performance reports.

@Netail Netail marked this pull request as ready for review January 22, 2026 16:43
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Jan 22, 2026

Walkthrough

This changeset introduces support for HTML element names that can be reference identifiers rather than just literal tag names. The grammar is updated to define AnyHtmlTagName as a union of HtmlTagName and HtmlReferenceIdentifier. Across the codebase, value_token() calls are systematically replaced with name_value_token() for proper token retrieval. New formatter implementations are added for the HtmlReferenceIdentifier type, and type signatures are propagated throughout linters, formatters, and utilities to consistently use AnyHtmlTagName instead of HtmlTagName.

Possibly related PRs

Suggested reviewers

  • ematipico
  • dyc3
  • arendjr
🚥 Pre-merge checks | ✅ 2
✅ Passed checks (2 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately describes the main change: adding support for element names being reference identifiers in the HTML parser.
Description check ✅ Passed The description relates to the changeset by explaining that it adds support for element names being reference identifiers, though it lacks specific implementation details.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
  • 📝 Generate docstrings

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Contributor

@dyc3 dyc3 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There aren't any actual changes to the HTML parser so that it emits the new node.

I think the way this should work is that HtmlReferenceIdentifier should only be emitted if we are in a template language file (.vue, .svelte, etc.)

node: &HtmlReferenceIdentifier,
f: &mut HtmlFormatter,
) -> FormatResult<()> {
format_html_verbatim_node(node.syntax()).fmt(f)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This needs to be actually formatted. This function marks the tokens as unformatted.

"@biomejs/biome": minor
---

Add support for the name of an element being a reference identifier
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: should be past tense, should also mention the HTML parser

Comment on lines +371 to +373
&& token
.text_trimmed()
.eq(token.text_trimmed().to_lowercase_cow().as_ref())
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you can check if its all lowercase without the potential allocation. you can .iter().any(...) to check if any char is uppercase.

let HtmlTagNameFields { value_token } = node.as_fields();

if should_lowercase_html_tag(f, node) {
if should_lowercase_html_tag(f, &node.clone().into()) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I feel like the cloning could be avoided here.

/// Returns `true` only for canonical HTML tags in pure HTML files (.html).
/// Component frameworks preserve tag name casing.
pub(crate) fn should_lowercase_html_tag(f: &HtmlFormatter, tag_name: &HtmlTagName) -> bool {
pub(crate) fn should_lowercase_html_tag(f: &HtmlFormatter, tag_name: &AnyHtmlTagName) -> bool {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I actually don't think this change is necessary, and it would let you avoid the clone I mentioned in my previous comment.

@Netail
Copy link
Member Author

Netail commented Jan 30, 2026

Oh, I think this has been covered with #8886 already

@Netail Netail closed this Jan 30, 2026
@Netail Netail deleted the feat/name-reference-identifier branch January 30, 2026 12:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-Formatter Area: formatter A-Linter Area: linter A-Parser Area: parser A-Tooling Area: internal tools L-HTML Language: HTML and super languages

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants