Repository navigation
fix(parser): report a known HTML element that is self closed - #719
Conversation
There was a problem hiding this comment.
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.
Codex Review Summary: ✅ CompletedThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
- `get_html_tag_definition` reads `is_known_element` (the schema's `allKnownElementNames()`) in place of a second hand-written copy of the 92 names, as upstream `html_tags.ts` builds them from `DomElementSchemaRegistry`. - Write the self-close condition as one `!(...)` (clippy nonminimal_bool). - Move the `ng-*` cases out of the namespace test into their own test. - Port upstream "should error when invalid html in the case" (`<b/>` in an ICU case). - Keep `ignores_decoys_elsewhere_in_the_source` as it was: it never parses the template. Co-Authored-By: Claude Opus 5.5 <[email protected]>
|
@codex review |
|
Codex Review: Didn't find any major issues. Keep them coming! Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback". |
<div/>and<span/>xcompile here without an error. ngc 22.2 reportsOnly 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 namestags.rsdefines (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 ascanSelfClose: false(html_tags.ts, fromDomElementSchemaRegistry.allKnownElementNames(), names without a namespace).Behaviour change
A template with a self-closed known HTML element (
<div/>,<span/>,<a/>, ...) that compiled with oxc before now reports the error, and that component is not compiled. This matches ngc, so projects that also build with ngc are not affected.Changes
get_html_tag_definitiongives every name of the DOM schema thattags.rsdoes not define the default definition, which cannot self close. The names come fromis_known_element(the crate's existing copy ofallKnownElementNames()), without the:svg:/:math:ones, the same way upstream builds them. Unknown names,ng-container,ng-templateandng-contentstill self close.<svg><div/></svg>stays valid. That isgetNsPrefix(fullName)upstream, wherefullNamecomes from_getElementFullName; here it isinherits_namespace()from fix(parser): don't treat an HTML void name in an svg or math namespace as void #667._consumeComponentStartTagnever reports it, so a selectorless<Button/>stays valid.Checks
html_parser_test.rs:should_report_self_closing_html_elementnow asserts the error (it only checked for a panic). New cases, each checked against ngc 22.2parseTemplate:<div/>,<span/>x,<DIV/>,<template/>,@if (a) {<div/>},<div/>insideforeignObject, and<b/>in an ICU case (upstream "should error when invalid html in the case") 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.svg,math,foreignObject,annotation-xml, blocks, with prefixes, and under selectorless components) gives the same self-close errors as ngc 22.2.2.<a/>,<b/>or<div/>: the sharedTWOfixture and three inline sources inhmr_fingerprint_test.rsnow write<a></a>/<b></b>, andshould_parse_self_closing_elementuses<my-cmp/>. Their assertions are unchanged.cargo test --workspace --all-features,cargo fmt --all -- --check, napivitest, the ngc compare fixtures and conformance (1430/1456, snapshot unchanged) pass.