Skip to content

fix(parser): report a known HTML element that is self closed - #719

Open
GabeSilvaDev wants to merge 1 commit into
voidzero-dev:mainfrom
GabeSilvaDev:fix/known-elements-self-close
Open

GabeSilvaDev wants to merge 1 commit into
voidzero-dev:mainfrom
GabeSilvaDev:fix/known-elements-self-close

Conversation

@GabeSilvaDev

Copy link
Copy Markdown
Contributor

<div/> and <span/>x compile here without an error. ngc 22.2 reports Only void, custom and foreign elements can be self closed "div" for both. This is the gap noted under "Not in this PR" in #667.

The check is already in consume_element_start, but it only fires for names tags.rs defines (p, li, td, ...). Every other name fell back to the unknown-tag definition, which can self close. Upstream also defines every element of its DOM schema as canSelfClose: false (html_tags.ts, from DomElementSchemaRegistry.allKnownElementNames(), names without a namespace).

Changes

  • get_html_tag_definition gives the 92 schema names tags.rs did not define the default definition, which cannot self close. The list is allKnownElementNames() from @angular/compiler 22.2.2, without the :svg:/:math: ones and the two [element]/[htmlelement] entries. Unknown names, ng-container, ng-template and ng-content still self close.
  • An element that takes a namespace from the element it is in is foreign, so <svg><div/></svg> stays valid. That is getNsPrefix(fullName) upstream, where fullName comes from _getElementFullName; here it is inherits_namespace() from fix(parser): don't treat an HTML void name in an svg or math namespace as void #667.
  • The check runs for element tags only. Upstream's _consumeComponentStartTag never reports it, so a selectorless <Button/> stays valid.

Checks

  • html_parser_test.rs: should_report_self_closing_html_element now asserts the error (it only checked for a panic). New cases, each checked against ngc 22.2 parseTemplate: <div/>, <span/>x, <DIV/>, <template/>, @if (a) {<div/>} and <div/> inside foreignObject report the error; <svg><div/></svg>, <math><span/></math>, <svg:div/>, <svg>@if (a) {<div/>}</svg>, <ng-container/>, <ng-template/>, <ng-content/> and a selectorless <Button/> don't.
  • Taking div out of the list, the inherited namespace, or the element-only condition each fails a test.
  • Five tests used a self-closed <a/>, <b/> or <div/> as their template. The four in hmr_fingerprint_test.rs now write <a></a>/<b></b>, and should_parse_self_closing_element uses <my-cmp/>. Their assertions are unchanged.
  • cargo test --all-features, cargo fmt --all -- --check and conformance (1430/1456, snapshot unchanged) pass.

Copilot AI balanced review requested due to automatic review settings November 15, 2026 22:34

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.

An organization owner can choose the repository organization as the billing source for reviews requested by members with a paid Copilot license. Learn about Copilot code review billing. Review the Copilot code review billing settings.

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 15, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-15T22:36:37.533457Z 31786da PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

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.

2 participants