Rename Icon path property to svgPath to fix type collision#1347
Rename Icon path property to svgPath to fix type collision#1347josemontespg wants to merge 18 commits intogoogle:mainfrom
Conversation
Rename the property inside the object from path to svgPath in IconApi schema. This breaks the structural match with DataBindingType and preserves the type in the union, avoiding the need for as any casts in renderers. TAG=agy CONV=2bdb6c04-2ba5-495e-8b59-e9981dd0ce1c
There was a problem hiding this comment.
Code Review
This pull request renames the path property to svgPath across the Angular, React, and Web Core implementations of the Icon component to clarify that it expects SVG path data. While the property rename is consistent, the React implementation needs to be updated to correctly render an <svg> element when svgPath is provided, as it currently incorrectly treats the path data as a Material Symbol ligature. Additionally, the unintentional pinning of the dompurify dependency in the React package lock should be reverted, and a description should be added to the svgPath Zod schema for better documentation.
…file change, and add schema description - Update React Icon component to render SVG when svgPath is provided. - Revert unintentional pinning of dompurify in React package-lock.json. - Add description to svgPath in IconApi schema. TAG=agy CONV=2bdb6c04-2ba5-495e-8b59-e9981dd0ce1c
- Update Lit Icon component to render SVG when svgPath is provided. - Update usages from path to svgPath. TAG=agy CONV=2bdb6c04-2ba5-495e-8b59-e9981dd0ce1c
TAG=agy CONV=2bdb6c04-2ba5-495e-8b59-e9981dd0ce1c
TAG=agy CONV=2bdb6c04-2ba5-495e-8b59-e9981dd0ce1c
TAG=agy CONV=2bdb6c04-2ba5-495e-8b59-e9981dd0ce1c
ditman
left a comment
There was a problem hiding this comment.
This is unfortunate, but makes sense. We should have a way to reserve these internal keywords at the protocol level, so this gets flagged earlier (and on custom components) (/cc @gspencergoog ?)
Also, IMO this is a technically breaking change, even though it never worked in the first place, it'll break cached responses; we should mark and release this as a breaking change.
TAG=agy CONV=2bdb6c04-2ba5-495e-8b59-e9981dd0ce1c
TAG=agy CONV=2bdb6c04-2ba5-495e-8b59-e9981dd0ce1c
# Conflicts: # renderers/angular/src/v0_9/catalog/basic/simple-components.spec.ts
TAG=agy CONV=2bdb6c04-2ba5-495e-8b59-e9981dd0ce1c
TAG=agy CONV=2bdb6c04-2ba5-495e-8b59-e9981dd0ce1c
I agree. Issue #1376 created to track Also updated the changelogs to mark this as a breaking change. |
|
There's some conflicts, but I think this is one of the last breaking changes that I see incoming; I'll use this as a break point to do a "next" release! |
# Conflicts: # renderers/lit/CHANGELOG.md # renderers/react/CHANGELOG.md # renderers/web_core/CHANGELOG.md
Problem
The
Iconcomponent'snameproperty accepts either a string (for standard icons) or an object with apathproperty (for custom SVG paths):However, the Angular renderer uses a utility type to resolve properties that strips away shapes matching
DataBindingType(which is defined as{ path: string }). Because of this structural match, the{ path: string }branch was being incorrectly excluded from the resolved type, leaving only the string enum and forcing developers to useas anycasts when dealing with custom SVG paths.Solution
This PR renames the property inside the object from
pathtosvgPath. This breaks the structural match withDataBindingTypeand preserves the type in the union, allowing for proper type inference without forced casts.Changes
IconApischema inweb_coreto usesvgPathand added documentation description.IconComponentto check for and usesvgPath. Updated tests to usesvgPath.Iconcomponent to usesvgPathand correctly render an<svg>element instead of a ligature span.Iconcomponent to usesvgPathand correctly render an<svg>element.as anycasts in the Angular icon component.