Repository navigation
fix(parser): report a known HTML element that is self closed - #719
GabeSilvaDev wants to merge 1 commit into
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. |
<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).Changes
get_html_tag_definitiongives the 92 schema namestags.rsdid not define the default definition, which cannot self close. The list isallKnownElementNames()from@angular/compiler22.2.2, without the:svg:/:math:ones and the two[element]/[htmlelement]entries. 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/>}and<div/>insideforeignObjectreport 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.divout of the list, the inherited namespace, or the element-only condition each fails a test.<a/>,<b/>or<div/>as their template. The four inhmr_fingerprint_test.rsnow write<a></a>/<b></b>, andshould_parse_self_closing_elementuses<my-cmp/>. Their assertions are unchanged.cargo test --all-features,cargo fmt --all -- --checkand conformance (1430/1456, snapshot unchanged) pass.