fix(html/codegen): keep </p> for span-parent paragraphs#11756
Conversation
🦋 Changeset detectedLatest commit: e6fd8ab The changes in this PR will be included in the next version bump. 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 |
PR Review: fix(html/codegen): keepfor span-parent paragraphsSummaryThis PR fixes #11748 by adding Code QualityThe fix is clean, minimal, and placed correctly. The comment explaining why Potential Issue: Incomplete CoverageThe HTML spec only lists
Any of these as a parent of Not a blocker for this PR — it's a reasonable targeted fix — but worth considering as a follow-up. Test CoverageGood. Both Minor Nits
VerdictLGTM for merge as a targeted fix. Consider a follow-up to generalize the exclusion to all phrasing content elements. |
There was a problem hiding this comment.
Pull request overview
Fixes HTML tag-omission behavior so </p> is not omitted when a <p> is the last child of a <span>, preserving browser parsing stability for invalid-but-common markup patterns (e.g. MDX output), as reported in #11748.
Changes:
- Update
swc_html_codegentag-omission rules to keep</p>when the parent element isspan. - Add regression fixtures for
swc_html_codegenand recovery fixtures forswc_html_minifiercoveringissue-11748. - Add a changeset entry for publishing/version bump.
Reviewed changes
Copilot reviewed 7 out of 7 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
crates/swc_html_codegen/src/lib.rs |
Prevent optional omission of </p> when the parent is <span> to avoid changing how invalid HTML is parsed. |
crates/swc_html_codegen/tests/fixture/issue-11748/* |
Regression fixture asserting minified output retains </p> under <span>. |
crates/swc_html_minifier/tests/recovery/element/issue-11748/* |
Recovery-mode fixture ensuring minifier output keeps </p> for the invalid nesting case. |
.changeset/neat-worms-vanish.md |
Declares release/version bump intent for this fix. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| @@ -0,0 +1,6 @@ | |||
| --- | |||
| swc_core: patch | |||
There was a problem hiding this comment.
The changeset includes swc_core: patch, but this PR doesn’t modify swc_core. This would trigger a swc_core version bump/release with no functional changes. Consider removing swc_core from the changeset (and listing only the affected crate(s), e.g. swc_html_codegen and any other crate you intend to publish for this fix).
| swc_core: patch |
Binary Sizes
Commit: 3c5484a |
Summary
</p>when the parent is<span>during HTML tag omissionswc_html_codegen(issue-11748)swc_html_minifier(issue-11748)Verification
cargo test -p swc_html_codegen --test fixture -- --ignored issue_11748cargo test -p swc_html_minifier --test fixture -- --ignored issue_11748cargo test -p swc_html_codegencargo test -p swc_html_minifiercargo fmt --allcargo clippy --all --all-targets -- -D warningsCloses #11748