Skip to content

feat: resolve icon aliases defined with use element in iconset - #12473

Merged
web-padawan merged 1 commit into
mainfrom
feat/iconset-aliases
Aug 24, 2026
Merged

web-padawan merged 1 commit into
mainfrom
feat/iconset-aliases

Conversation

@web-padawan

@web-padawan web-padawan commented Aug 24, 2026 •

Copy link
Copy Markdown
Member

Description

Extracted from #12452

  • Added support for icon aliases in Iconset: an entry that contains a single <use href="#..."> pointing at another entry now resolves to the entry it points at.
    • This lets an iconset expose a new name for an existing icon without duplicating the SVG content, which is needed to rename icons in @vaadin/icons while keeping the old names working.
  • An alias must point at a regular icon. Aliases are looked up in a copy of the icon map, so an alias pointing at another alias renders nothing regardless of the order in which the entries are declared.
  • Added a test rendering an alias through vaadin-icon.

Type of change

  • Feature

How to test

  1. Open dev/icon.html.
  2. In the browser console, add an iconset with an alias and render it:
    document.body.insertAdjacentHTML(
      'beforeend',
      `<vaadin-iconset name="test" size="16">
         <svg><defs>
           <g id="test:caret-down"><path d="M3 4h10l-5 7z"></path></g>
           <g id="test:alias"><use href="#test:caret-down"></use></g>
         </defs></svg>
       </vaadin-iconset>
       <vaadin-icon icon="test:alias"></vaadin-icon>`,
    );
  3. The last icon on the page should render the caret-down shape instead of staying empty.

🤖 Generated with Claude Code

@vaadin-review-bot vaadin-review-bot left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Reviewed the changes — left 2 comments.

Finding
⚠️ Alias chains resolve or break depending on document order, because the loop reads the same map it mutates
🧪 The alias test's only meaningful assertion inspects the private _icons map, and the other one cannot fail

Comment thread packages/icon/test/iconset.test.js Resolved
@web-padawan
web-padawan force-pushed the feat/iconset-aliases branch 2 times, most recently from 22f5816 to c915b63 Compare August 24, 2026 08:38
An iconset entry that contains a single `<use href="#...">` pointing at
another entry in the same iconset is now mapped to that entry. This allows
the Vaadin iconset to expose new names for existing icons without
duplicating the SVG content.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
@web-padawan
web-padawan force-pushed the feat/iconset-aliases branch from c915b63 to b11cfee Compare August 24, 2026 08:42
@sonarqubecloud

Copy link
Copy Markdown

@web-padawan
web-padawan requested a review from jouni August 24, 2026 08:45
@web-padawan
web-padawan merged commit 1023fa8 into main Aug 24, 2026
13 checks passed
@web-padawan
web-padawan deleted the feat/iconset-aliases branch August 24, 2026 09:13
@vaadin-bot

Copy link
Copy Markdown
Collaborator

This ticket/PR has been released with Vaadin 25.3.0.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants