Skip to content

Icons: Normalize SVG icons on commit and validate them in the build - #86657

Merged
t-hamano merged 10 commits into
trunkfrom
update/icons-svg-validation
Nov 17, 2026
Merged

t-hamano merged 10 commits into
trunkfrom
update/icons-svg-validation

Conversation

@t-hamano

@t-hamano t-hamano commented Nov 11, 2026 •

Copy link
Copy Markdown
Contributor

What?

Supersedes #85272.

Add a normalize-svg script to the icons package that converts a design-tool SVG export into the format the library uses.

Why?

When you export an icon from a design tool such as Figma, the SVG does not match the format this library uses, and fixing it by hand for every icon is tedious and easy to get wrong. Until now, the build validated only part of the SVG markup, and it only reported problems without fixing them.

How?

  • A new script, npm run normalize-svg, converts an exported icon into the library format. For example, it removes the fixed size and sets the color in one place, so the icon follows the color of the surrounding text.
  • validate-collection.cjs no longer has its own SVG checks, and focuses on the icon manifest instead. For each SVG, it only checks whether the new script would change the file or cannot convert it. If so, the icon is not normalized, and the build fails.
  • The script runs automatically when you commit an icon.
  • The same check runs when the icons are built, so CI catches a problem even if the check at commit time was skipped.

Testing Instructions

  1. Run npm run test:unit -- packages/icons/lib/test.
  2. Run npm run -w packages/icons build and confirm it passes.
  3. Export an icon drawn in Figma into packages/icons/src/library/, add it to manifest.json, stage it and commit. Confirm the committed file is normalized.
  4. Export a frame with "Clip content" turned on, or add stroke-width="2" to a path in a library icon, and confirm the commit and the build both fail with a message naming the icon and the problem.

Use of AI Tools

This PR was written with Claude Code and reviewed by me.

@t-hamano t-hamano added [Type] Code Quality Issues or PRs that relate to code quality [Package] Icons /packages/icons labels Nov 11, 2026
@t-hamano t-hamano self-assigned this Nov 11, 2026
@github-actions

github-actions Bot commented Nov 11, 2026 •

Copy link
Copy Markdown

🤖 PR meta 🤖

Preview in WordPress Playground Preview in Storybook

🎉 Props

If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message.

Co-authored-by: jasmussen <joen@git.wordpress.org>
Co-authored-by: t-hamano <wildworks@git.wordpress.org>
Co-authored-by: ciampo <mciampini@git.wordpress.org>
Co-authored-by: mirka <0mirka00@git.wordpress.org>

To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook.


Props Bot commands

You can trigger Props Bot actions by commenting on this PR:

  • @propsbot add <username> to give props to a GitHub user. Requires write access.
  • @propsbot remove <username> to leave a user out of the props. Requires write access.
  • @propsbot refresh to refresh this list. Adding the props-bot label works too.

Updated as activity occurs, without notifying anyone named here. Add the props-bot label to refresh.

📦 Bundle size

Size Change: 0 B

Total Size: 8.66 MB

c5057bd Run

⚡ Performance

Show the results

Client side metrics exclude the server response time.

front-end-block-theme

Metric 65748e9 trunk % Change
timeToFirstByte 56.75 ms +4.85% -3.96% 56.25 ms +5.42% -3.56% 0.89%
largestContentfulPaint 92 ms +4.35% -4.35% 86 ms +4.65% -2.33% 6.98%
lcpMinusTtfb 30.65 ms +27.41% -4.08% 28.65 ms +16.75% -3.14% 6.98%
wpBeforeTemplate 29.62 ms +12.96% -3.51% 29.4 ms +9.08% -2.38% 0.75%
wpTemplate 22.83 ms +3.24% -4.99% 22.07 ms +4.4% -2.85% 3.44%
wpTotal 52.96 ms +4.87% -4.19% 52.28 ms +5.34% -3.42% 1.3%
wpMemoryUsage 7.75 MB +0% -0% 7.71 MB +0% -0% 0.45%
wpDbQueries 16 +0% -0% 16 +0% -0% 0%

front-end-classic-theme

Metric 65748e9 trunk % Change
timeToFirstByte 47.75 ms +7.23% -3.87% 46.7 ms +5.14% -1.18% 2.25%
largestContentfulPaint 84 ms +2.38% -4.76% 80 ms +5% -0% 5%
lcpMinusTtfb 34.7 ms +5.48% -2.16% 33.95 ms +3.68% -0.74% 2.21%
wpBeforeTemplate 26.86 ms +11.62% -2.01% 26.21 ms +5.72% -0.53% 2.48%
wpTemplate 16.57 ms +3.56% -2.53% 17.15 ms +1.75% -3.73% -3.38%
wpTotal 43.82 ms +7.21% -2.4% 43.57 ms +5% -1.19% 0.57%
wpMemoryUsage 6.44 MB +0% -0% 6.40 MB +0% -0% 0.56%
wpDbQueries 13 +0% -0% 13 +0% -0% 0%

media-processing

Metric 65748e9 trunk % Change
mediaProcessingJpeg 402.35 ms +1.3% -0.67% 401.69 ms +1.13% -1.23% 0.16%
mediaProcessingAvif 6133.85 ms +0.28% -0.43% 6178.94 ms +0.23% -0.23% -0.73%
mediaProcessingJpegToAvif 4216.16 ms +0.13% -0.16% 4257.06 ms +0.19% -0.16% -0.96%

media-upload

Metric 65748e9 trunk % Change
jpegUploadProcessing 1997.34 ms +1.86% -25.02% 1521.04 ms +2.95% -1% 31.31%
pngUploadProcessing 277.23 ms +3.01% -2.6% 280.51 ms +0.96% -3.77% -1.17%
largeJpegUploadProcessing 1536.17 ms +28.19% -2.09% 1545.65 ms +28.89% -2.3% -0.61%
multipleImageUploadProcessing 2081.77 ms +1.03% -0.31% 2083.27 ms +0.73% -1.5% -0.07%

post-editor

Metric 65748e9 trunk % Change
serverResponse 328.58 ms +1.35% -10.07% 311.44 ms +6.17% -6.07% 5.5%
firstPaint 324.77 ms +5.79% -3.66% 343.8 ms +6.06% -10.58% -5.54%
domContentLoaded 662.36 ms +0.88% -1.4% 652.11 ms +0.48% -1.7% 1.57%
loaded 663.23 ms +0.9% -1.36% 653.09 ms +0.49% -1.71% 1.55%
firstContentfulPaint 378.96 ms +1.37% -1.25% 369.86 ms +3.38% -1.52% 2.46%
firstBlock 1767.52 ms +2.35% -1.71% 1739.68 ms +1.08% -1.26% 1.6%
type 16.13 ms +3.6% -11.04% 15.7 ms +4.78% -9.04% 2.74%
typeWithoutInspector 16.27 ms +7.13% -10.63% 15.5 ms +1.87% -10.84% 4.97%
typeWithTopToolbar 20.4 ms +6.37% -6.52% 19.66 ms +7.73% -10.58% 3.76%
typeContainer 7.17 ms +7.53% -15.34% 7.11 ms +7.45% -14.35% 0.84%
focus 104.64 ms +7.65% -9.8% 96.64 ms +7.67% -4.35% 8.28%
firstFocus 215.92 ms +0% -0% 205.72 ms +0% -0% 4.96%
selectAll 314.01 ms +8.26% -0.37% 333.38 ms +3.15% -5.98% -5.81%
undo 26.05 ms +5.76% -5.3% 24.84 ms +6.36% -5.6% 4.87%
listViewOpen 64.34 ms +5.24% -10.34% 57.78 ms +6.96% -8.32% 11.35%
inserterOpen 34.39 ms +6.8% -4.48% 33.17 ms +5.03% -3.5% 3.68%
inserterHover 9.64 ms +2.49% -6.22% 9.73 ms +3.29% -8.84% -0.92%
inserterSearch 7 ms +7.43% -8.29% 6.5 ms +11.69% -4.31% 7.69%
loadPatterns 525.62 ms +7.22% -3.48% 521.23 ms +2.2% -3.3% 0.84%
wpTotal 319.9 ms +1.41% -10.4% 302.62 ms +6.31% -6.19% 5.71%
wpMemoryUsage 14.81 MB +0% -0% 14.77 MB +0% -0% 0.25%
wpDbQueries 55 +0% -0% 55 +0% -0% 0%

site-editor

Metric 65748e9 trunk % Change
serverResponse 319.1 ms +0.8% -1.68% 321.94 ms +0.3% -0.67% -0.88%
firstPaint 329.77 ms +7.44% -8.48% 319.55 ms +17.89% -6.04% 3.2%
domContentLoaded 676.41 ms +2.42% -0.94% 657.24 ms +0.86% -0.68% 2.92%
loaded 677.2 ms +2.47% -0.91% 658.12 ms +0.85% -0.66% 2.9%
firstContentfulPaint 377.53 ms +3.47% -1.78% 374.65 ms +1.57% -3.34% 0.77%
firstBlock 2043.48 ms +3.05% -1.38% 2011.03 ms +0.86% -0.58% 1.61%
type 15.7 ms +4.08% -7.96% 15.09 ms +10.74% -9.01% 4.04%
navigate 91.51 ms +6.97% -7.66% 90.78 ms +2.42% -1.63% 0.8%
loadPatterns 1086.59 ms +8.32% -5.54% 1135.04 ms +5.32% -6.58% -4.27%
loadPages 940.49 ms +5.76% -2.96% 986.41 ms +1.66% -6.97% -4.66%
wpTotal 310.21 ms +1.01% -1.53% 313.64 ms +0.29% -0.69% -1.09%
wpMemoryUsage 12.82 MB +0% -0% 12.79 MB +0% -0% 0.25%
wpDbQueries 45 +0% -0% 45 +0% -0% 0%

c5057bd Run

🏁 Flaky tests

Some tests passed with failed attempts. The failures may not be related to this commit but are still reported for visibility. See the documentation for more information.

should apply a named font size using the font size buttons in /test/e2e/specs/editor/various/font-size-picker.spec.js, passed after 1 failed attempt.
Error: expect(received).toBe(expected) // Object.is equality

- Expected  - 2
+ Received  + 2

- <!-- wp:paragraph {"fontSize":"large"} -->
+ <!-- wp:paragraph {"fontSize":"medium"} -->
- <p class="has-large-font-size">Paragraph to be made "large"</p>
+ <p class="has-medium-font-size">Paragraph to be made "large"</p>
  <!-- /wp:paragraph -->

Call Log:
- Timeout 5000ms exceeded while waiting on the predicate
    at /home/runner/work/gutenberg/gutenberg/test/e2e/specs/editor/various/font-size-picker.spec.js:153:6
should reset a named font size using input field in /test/e2e/specs/editor/various/font-size-picker.spec.js, passed after 1 failed attempt.
Error: expect(received).toBe(expected) // Object.is equality

- Expected  - 2
+ Received  + 2

- <!-- wp:paragraph {"fontSize":"small"} -->
+ <!-- wp:paragraph {"fontSize":"tiny"} -->
- <p class="has-small-font-size">Paragraph with font size reset using input field</p>
+ <p class="has-tiny-font-size">Paragraph with font size reset using input field</p>
  <!-- /wp:paragraph -->

Call Log:
- Timeout 5000ms exceeded while waiting on the predicate
    at /home/runner/work/gutenberg/gutenberg/test/e2e/specs/editor/various/font-size-picker.spec.js:216:6
should reset a named font size using the tools panel menu in /test/e2e/specs/editor/various/font-size-picker.spec.js, passed after 1 failed attempt.
Error: expect(received).toBe(expected) // Object.is equality

- Expected  - 2
+ Received  + 2

- <!-- wp:paragraph {"fontSize":"medium"} -->
+ <!-- wp:paragraph {"fontSize":"small"} -->
- <p class="has-medium-font-size">Paragraph with font size reset using tools panel menu</p>
+ <p class="has-small-font-size">Paragraph with font size reset using tools panel menu</p>
  <!-- /wp:paragraph -->

Call Log:
- Timeout 5000ms exceeded while waiting on the predicate
    at /home/runner/work/gutenberg/gutenberg/test/e2e/specs/editor/various/font-size-picker.spec.js:178:6
should select synced pattern in /test/e2e/specs/editor/various/writing-flow.spec.js, passed after 1 failed attempt.
Error: expect(locator).toBeFocused() failed

Locator:  locator('[name="editor-canvas"]').contentFrame().locator('[data-type="core/block"]')
Expected: focused
Received: inactive
Timeout:  5000ms

Call log:
  - Expect "toBeFocused" locator('[name="editor-canvas"]').contentFrame().locator('[data-type="core/block"]') with timeout 5000ms
  - waiting for locator('[name="editor-canvas"]').contentFrame().locator('[data-type="core/block"]')
    14 × locator resolved to <div tabindex="0" role="document" draggable="true" data-title="Pattern" data-type="core/block" data-is-drop-zone="true" aria-label="Block: Pattern" id="block-8b29c0d6-c125-4ee2-b29b-279aca949c19" data-block="8b29c0d6-c125-4ee2-b29b-279aca949c19" class="block-editor-block-list__block wp-block is-selected is-reusable block-library-block__reusable-block-container wp-block-block block-editor-block-list__layout">…</div>
       - unexpected value "inactive"

    at /home/runner/work/gutenberg/gutenberg/test/e2e/specs/editor/various/writing-flow.spec.js:1464:5
shows hidden notes when adding a note in /test/e2e/specs/editor/various/block-notes-floating.spec.js, passed after 1 failed attempt.
Error: locator.click: Error: strict mode violation: getByRole('region', { name: 'Editor top bar' }).getByRole('button', { name: 'Options' }) resolved to 2 elements:
    1) <button id="_r_18_" type="button" tabindex="-1" aria-haspopup="true" aria-label="Options" aria-expanded="false" data-toolbar-item="true" class="components-button components-dropdown-menu__toggle has-icon">…</button> aka getByRole('toolbar', { name: 'Block tools' }).getByRole('button', { name: 'Options' })
    2) <button tabindex="0" type="button" id="base-ui-_r_k_" aria-haspopup="menu" aria-label="Options" aria-expanded="false" class="components-button is-compact has-icon">…</button> aka locator('#base-ui-_r_k_')

Call log:
  - waiting for getByRole('region', { name: 'Editor top bar' }).getByRole('button', { name: 'Options' })

    at BlockNoteUtils.clickNotesMenuItem (/home/runner/work/gutenberg/gutenberg/test/e2e/specs/editor/various/block-notes-utils.js:135:5)
    at /home/runner/work/gutenberg/gutenberg/test/e2e/specs/editor/various/block-notes-floating.spec.js:1291:25
templates can be registered and edited (Site Editor v2) in /test/e2e/specs/site-editor/template-registration.spec.js, passed after 1 failed attempt.
Error: expect(locator).toBeVisible() failed

Locator: getByText('AuthorGutenberg')
Expected: visible
Error: strict mode violation: getByText('AuthorGutenberg') resolved to 3 elements:
    1) <div data-wp-c16t="true" data-wp-component="Flex" class="_463056a1846babdd__flex eefcc0383f58d3a1__items-row _8a741740b23dfb57__expanded-row components-flex dataviews-view-grid__field">…</div> aka getByRole('row', { name: 'Row 1' }).getByText('AuthorGutenberg')
    2) <div data-wp-c16t="true" data-wp-component="Flex" class="_463056a1846babdd__flex eefcc0383f58d3a1__items-row _8a741740b23dfb57__expanded-row components-flex dataviews-view-grid__field">…</div> aka locator('[id="emptytheme//page"]').getByText('AuthorGutenberg')
    3) <div data-wp-c16t="true" data-wp-component="Flex" class="_463056a1846babdd__flex eefcc0383f58d3a1__items-row _8a741740b23dfb57__expanded-row components-flex dataviews-view-grid__field">…</div> aka locator('[id="emptytheme//plugin-template"]').getByText('AuthorGutenberg')

Call log:
  - Expect "toBeVisible" getByText('AuthorGutenberg') with timeout 5000ms
  - waiting for getByText('AuthorGutenberg')

    at /home/runner/work/gutenberg/gutenberg/test/e2e/specs/site-editor/template-registration.spec.js:60:55
three users concurrently edit a large post with diverse blocks in /test/e2e/specs/editor/collaboration/collaboration-stress.spec.ts, passed after 2 failed attempts.
TimeoutError: locator.waitFor: Timeout 17500ms exceeded.
Call log:
  - waiting for getByRole('button', { name: /Collaborators list/ }) to be visible

    at map (/home/runner/work/gutenberg/gutenberg/test/e2e/specs/editor/collaboration/fixtures/collaboration-utils.ts:193:7)
    at CollaborationUtils.waitForMutualDiscovery (/home/runner/work/gutenberg/gutenberg/test/e2e/specs/editor/collaboration/fixtures/collaboration-utils.ts:188:10)
    at /home/runner/work/gutenberg/gutenberg/test/e2e/specs/editor/collaboration/collaboration-stress.spec.ts:416:28
TimeoutError: locator.waitFor: Timeout 17500ms exceeded.
Call log:
  - waiting for getByRole('button', { name: /Collaborators list/ }) to be visible

    at map (/home/runner/work/gutenberg/gutenberg/test/e2e/specs/editor/collaboration/fixtures/collaboration-utils.ts:193:7)
    at CollaborationUtils.waitForMutualDiscovery (/home/runner/work/gutenberg/gutenberg/test/e2e/specs/editor/collaboration/fixtures/collaboration-utils.ts:188:10)
    at /home/runner/work/gutenberg/gutenberg/test/e2e/specs/editor/collaboration/collaboration-stress.spec.ts:416:28

c5057bd Run

@t-hamano
t-hamano changed the base branch from add/icon-normalize-script to trunk November 11, 2026 09:50
@@ -1,3 +1,3 @@
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" style="fill: none" stroke="currentColor" stroke-width="1.5">
<rect x="5" y="5" width="14" height="14" rx="2" stroke="currentColor" />
<rect x="5" y="5" width="14" height="14" rx="2" />

@t-hamano t-hamano Nov 11, 2026 •

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

This shape repeated the root's stroke="currentColor", so the script removed the redundant attribute. The icon looks the same.

@t-hamano t-hamano Nov 11, 2026 •

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

To match the role of validateCollection(), the SVG tests here are now limited to checking that it turns the result of normalizeIconSvg() into a pass or a failure. The SVG rules themselves are covered in normalize-icon-svg.js.

  • accepts a normalized icon
  • rejects an icon that is not normalized
  • rejects an icon that cannot be normalized

@t-hamano t-hamano Nov 11, 2026 •

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

This file holds the core logic of this PR. Sorry it is long. To see what it is trying to do, the unit tests in lib/test/normalize-icon-svg.js are the quickest read.

@t-hamano
t-hamano force-pushed the update/icons-svg-validation branch from f3dd806 to 583042a Compare November 11, 2026 12:18
…lizer

Co-authored-by: Joen A. <joen@automattic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_011g9URwrK9Tye4Yh48WoaqB
@t-hamano
t-hamano force-pushed the update/icons-svg-validation branch from 583042a to c4ebbb8 Compare November 11, 2026 12:20
@t-hamano t-hamano changed the title Icons: Validate library SVGs through normalize-svg Icons: Normalize SVG icons on commit and validate them in the build Nov 11, 2026
@t-hamano
t-hamano marked this pull request as ready for review November 11, 2026 12:25
@t-hamano
t-hamano requested a review from jasmussen as a code owner November 11, 2026 12:25
@t-hamano
t-hamano requested review from a team and mcsf November 11, 2026 12:25
@t-hamano

Copy link
Copy Markdown
Contributor Author

@jasmussen, I haven't made icons in Figma very often, so I would really appreciate it if you could test whether this script works properly.

@jasmussen

jasmussen commented Nov 11, 2026 •

Copy link
Copy Markdown
Contributor

Thanks a ton for your help here. This is the public workspace for icons. From it, I exported header as a test, as it contains both strokes and fills, and the strokes are often intersecting. Here's the exported SVG code, raw from Figma:

<svg width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
<path d="M9.75 19.25H18C18.6904 19.25 19.25 18.6904 19.25 18V9.75M9.75 19.25H6C5.30964 19.25 4.75 18.6904 4.75 18V9.75M9.75 19.25V9.75M19.25 9.75V6C19.25 5.30964 18.6904 4.75 18 4.75H6C5.30964 4.75 4.75 5.30964 4.75 6V9.75M19.25 9.75H9.75M9.75 9.75H4.75" stroke-width="1.5" stroke="black"/>
<path d="M19.25 8.5V6C19.25 5.30964 18.6904 4.75 18 4.75H6C5.30964 4.75 4.75 5.30964 4.75 6V8.5C4.75 9.19036 5.30964 9.75 6 9.75H18C18.6904 9.75 19.25 9.19036 19.25 8.5Z" fill="black" stroke-width="1.5" stroke="black"/>
</svg>

Here it is after running the git commit command locally:

<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" style="fill: none" stroke="currentColor" stroke-width="1.5">
	<path d="M9.75 19.25H18C18.6904 19.25 19.25 18.6904 19.25 18V9.75M9.75 19.25H6C5.30964 19.25 4.75 18.6904 4.75 18V9.75M9.75 19.25V9.75M19.25 9.75V6C19.25 5.30964 18.6904 4.75 18 4.75H6C5.30964 4.75 4.75 5.30964 4.75 6V9.75M19.25 9.75H9.75M9.75 9.75H4.75" />
	<path d="M19.25 8.5V6C19.25 5.30964 18.6904 4.75 18 4.75H6C5.30964 4.75 4.75 5.30964 4.75 6V8.5C4.75 9.19036 5.30964 9.75 6 9.75H18C18.6904 9.75 19.25 9.19036 19.25 8.5Z" fill="currentColor" />
</svg>

Looks pretty good to me, and the icon renders the same before and after. Notably it maintained the fill="currentColor" prop on the highlighted part of the header.

@jasmussen jasmussen left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This probably needs a gut-check beyond my own, but from my usage, this fits the bill.

@t-hamano

Copy link
Copy Markdown
Contributor Author

@jasmussen Thanks for testing! Let's leave this PR open for a bit to see if we can get a code review from someone else.

Comment on lines +373 to +376
const fill = attributes.fill ?? rootFill;
const stroke = attributes.stroke ?? rootStroke;
const isFilled = isPainted( fill );
const isStroked = isPainted( stroke );

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

A fill such as #00000080 is accepted and rewritten to currentColor, which makes a half-transparent shape opaque. Could we preserve its alpha or reject paint values that cannot be converted safely, with a regression test?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Good catch. Keeping the alpha in the color value would conflict with the rule that every shape inherits currentColor, and converting it to opacity automatically has too many edge cases to handle reliably. Instead, the script now rejects a paint value with an alpha channel and suggests using the opacity attribute instead.

Fixed in 6ca6973

Comment on lines +267 to +273
for ( const key of [ 'fill', 'stroke' ] ) {
if ( attributes[ key ]?.startsWith( 'url(' ) ) {
problems.push(
`${ key }="${ attributes[ key ] }" on <${ name }> (a library icon is drawn in a single color that inherits the text color)`
);
}
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This check misses fill and stroke inherited from the root, so a root fill="url(#missing) none" is silently converted to a solid fill. Could we reject paint-server references on the root as well?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Fixed in 3350586.The url( check now runs on the effective paint of each shape, so a paint server inherited from the root is rejected too.

Comment on lines +323 to +328
if ( METADATA_ELEMENTS.includes( name ) ) {
if ( ! isClosing ) {
droppedMetadata += 1;
}
continue;
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This skips the metadata tags but still processes their contents: RDF metadata is rejected, and a path inside <metadata> is moved into the visible drawing. Could we skip the whole subtree and cover structured metadata in the tests?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Fixed in e66c2e6. The script now skips everything inside <metadata>.

Comment on lines +412 to +421
const colors = [
...new Set( shapes.flatMap( ( shape ) => shape.colors ) ),
];
if ( colors.length > 1 ) {
problems.push(
`more than one color (${ colors.join(
', '
) }; a library icon is drawn in a single color that inherits the text color, so a cut-out has to be part of the path, for example with fill-rule="evenodd")`
);
}

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This compares color strings, so #000 next to black, or #1e1e1e next to currentColor counts as two colors. Both errors then point the author at fill-rule="evenodd" cut-outs, which isn't the problem.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Fixed in 852ba4d. Colors are now normalized before they are compared. For named colors, only black and white are normalized, so mixing another name with its hex value, such as red and #ff0000, still fails as before.

A fill such as `#80` was rewritten to `currentColor`, which made a
translucent shape opaque. Reject it instead and point the author at the
`opacity` attribute.

Co-authored-by: t-hamano <54422211+t-hamano@users.noreply.github.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_011g9URvtxMTaiyorUJMSgTD
@github-actions
github-actions Bot requested review from aduth and ciampo November 17, 2026 06:59
claude and others added 4 commits November 17, 2026 07:03
The `url(` check only looked at a shape's own attributes, so a root
`fill="url(#missing) none"` was silently converted to a solid fill.
Check the effective paint of each shape instead.

Co-authored-by: t-hamano <54422211+t-hamano@users.noreply.github.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_011g9URvtxMTaiyorUJMSgTD
Only the metadata tags themselves were skipped, so RDF licensing inside
`<metadata>` was rejected and a shape inside it was moved into the
visible drawing. Skip the whole subtree instead.

Co-authored-by: t-hamano <54422211+t-hamano@users.noreply.github.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_011g9URvtxMTaiyorUJMSgTD
A duplicate was only reported as a note, which neither the commit hook
nor the build shows, so an already normalized icon with a stray copied
layer passed silently. Fail instead.

Co-authored-by: t-hamano <54422211+t-hamano@users.noreply.github.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_011g9URvtxMTaiyorUJMSgTD
The build fails on any icon that the script would change on a second
pass, so check that each conversion's output normalizes to itself.

Co-authored-by: t-hamano <54422211+t-hamano@users.noreply.github.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_011g9URvtxMTaiyorUJMSgTD
claude and others added 2 commits November 17, 2026 07:56
Colors were compared as strings, so `#000` next to `black` counted as
two colors, and the error always pointed at `fill-rule="evenodd"`
cut-outs. Compare common color forms by value, and ask for one color
first, mentioning cut-outs only as one cause.

Co-authored-by: t-hamano <54422211+t-hamano@users.noreply.github.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_011g9URvtxMTaiyorUJMSgTD
The commit hook writes, and the build checks through
`validateCollection()`, so `--check` had no caller and no test.

Co-authored-by: t-hamano <54422211+t-hamano@users.noreply.github.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_011g9URvtxMTaiyorUJMSgTD
t-hamano and others added 2 commits November 17, 2026 21:18
Co-authored-by: t-hamano <54422211+t-hamano@users.noreply.github.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_011g9URytMUm4YLQnu9zcC4i
@t-hamano
t-hamano merged commit 6db8421 into trunk Nov 17, 2026
86 of 93 checks passed
@t-hamano
t-hamano deleted the update/icons-svg-validation branch November 17, 2026 13:33
@github-actions github-actions Bot added this to the Gutenberg 24.5 milestone Nov 17, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

[Package] Icons /packages/icons [Type] Code Quality Issues or PRs that relate to code quality

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants