Broaden HTML module source URL coverage (SVG, legacy & obsolete attributes)#21241
Merged
Conversation
…und URLs Add SVG reference elements (color-profile, filter, pattern, linearGradient, radialGradient) and the deprecated presentational background attribute (body, table, td, th) to the HTML module's default source list so their external URLs are emitted as assets.
Handle CSS FuncIRI url(...) values in SVG presentation attributes (fill, stroke, clip-path, mask, filter, marker-*, cursor) by reusing webpack's CSS lexer (TokenStream) to locate the url spans. External url(file.svg#id) references become assets; internal url(#id) refs are left untouched. Gated to the SVG namespace and disabled with `sources: false`.
Add legacy preview-image hints (`<link rel=image_src>`, `<meta name=thumbnail>`) and obsolete element source attributes (`<object classid>`, `<param valuetype=ref value>`, `<applet code/object>`, MathML `<mglyph src>`) to the HTML module's default source list.
The manifest file is emitted as an asset, but its JSON icons/screenshots/ shortcuts URLs are not yet rewritten; this needs a dedicated webmanifest module type rather than a source-table entry.
🦋 Changeset detectedLatest commit: 3c86c87 The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
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 |
Contributor
|
This PR is packaged and the instant preview is available (3aec563). Install it locally:
npm i -D webpack@https://pkg.pr.new/webpack@3aec563
yarn add -D webpack@https://pkg.pr.new/webpack@3aec563
pnpm add -D webpack@https://pkg.pr.new/webpack@3aec563 |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #21241 +/- ##
==========================================
+ Coverage 92.76% 92.80% +0.03%
==========================================
Files 591 589 -2
Lines 64565 64594 +29
Branches 17957 17968 +11
==========================================
+ Hits 59896 59946 +50
+ Misses 4669 4648 -21
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
Codecov only counts the unit flag, so the configCases integration tests don't register. Add HtmlParser.unittest.js cases driving real ASTs through the new SVG presentation url(), paint-server/reference, and legacy/obsolete attribute paths so the patch coverage reflects them.
The svg-paint-server-references snapshot embeds the content hash of the emitted sRGB.icc asset. Under `* text=auto`, Windows checkout rewrote the fixture's newline to CRLF, changing the hash and failing the snapshot. Add `eol=lf` for the new html test dirs (matching the existing html fixtures) so the bytes — and the hash — are identical on every platform.
Contributor
Types CoverageCoverage after merging claude/html-module-coverage-ssl7ib into main will be
Coverage Report
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Expands the set of URL-bearing tags/attributes the experimental HTML module (
experiments.html) extracts as webpack dependencies, closing several gaps found while auditingHtmlParser:href/xlink:href:<linearGradient>,<radialGradient>,<pattern>,<filter>, plus<color-profile>(external ICC profile).fill,stroke,clip-path,mask,filter,marker-*,cursor) — theirurl(...)references, by reusing webpack's CSS lexer (TokenStream) to locate the spans; internalurl(#id)is left untouched.backgroundattribute on<body>/<table>/<td>/<th>.<link rel="image_src">,<meta name="thumbnail">) and obsolete element attributes (<object classid>,<param valuetype="ref" value>,<applet code/object>, MathML<mglyph src>).External (
https:,data:, …) and fragment-only (#id) references are left untouched, consistent with existing behavior. ATODOis left for parsing web app manifest contents (icons/screenshots/shortcutsURLs), which needs a dedicated webmanifest module type rather than a source-table entry.What kind of change does this PR introduce?
feat — new extraction coverage in the experimental HTML modules support.
Did you add tests for your changes?
Yes — new
test/configCases/html/cases:svg-paint-server-references,svg-presentation-url,legacy-background, andlegacy-and-obsolete-sources(each also covering the negative cases, e.g. fragment-only refs and a<param>withoutvaluetype="ref"are left untouched).Does this PR introduce a breaking change?
No. It only adds new default source extraction for HTML modules, which is behind the experimental
experiments.htmlflag.If relevant, what needs to be documented once your changes are merged or what have you already documented?
When HTML module support is documented, the expanded default source list (the tags/attributes above) should be reflected in the
module.parser.html.sourcesreference.Use of AI
AI (Claude) was used to investigate the source-coverage gaps, implement the additions, and write the tests; all changes were reviewed and verified against the existing test suite before submitting.
Generated by Claude Code