Skip to content

refactor: simplify icon rendering logic, inline some methods - #9333

Merged
web-padawan merged 1 commit into
mainfrom
refactor/icon-simplify-render
May 29, 2025
Merged

web-padawan merged 1 commit into
mainfrom
refactor/icon-simplify-render

Conversation

@web-padawan

Copy link
Copy Markdown
Member

Description

Updated vaadin-icon to pass svg directly to the render() method without storing a reference to the <g> element - this was only needed with Polymer. Also inlined methods that were extracted due to Polymer into the render().

Type of change

  • Refactor

@web-padawan
web-padawan requested a review from vursen May 29, 2025 07:16

/** @private */
__svgElement: String,
__useRef: String,

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Fixed the type, __useRef was incorrectly using Object and __svgElement incorrectly using String 🙈

this._applyIcon();
} else {
this.svg = ensureSvgLiteral(null);
this.svg = null;

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Calling ensureSvgLiteral here results in it being called twice. It's enough to call it inside render().


it('should set default preserveAspectRatio attribute when not set on the icon', () => {
icon.icon = 'vaadin:angle-down';
expect(svgElement.getAttribute('preserveAspectRatio')).to.equal('xMidYMid meet');

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

The default value was not covered by any unit tests so I added a test for it.

@sonarqubecloud

Copy link
Copy Markdown

@web-padawan
web-padawan merged commit b284ab0 into main May 29, 2025
@web-padawan
web-padawan deleted the refactor/icon-simplify-render branch May 29, 2025 08:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants