Skip to content

Commit

Permalink
fix: reflect icon property as an attribute (#6327) (#6328)
Browse files Browse the repository at this point in the history
Co-authored-by: Tomi Virkki <[email protected]>
  • Loading branch information
vaadin-bot and tomivirkki authored Aug 9, 2023
1 parent 1853b0a commit 0a9e65b
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 0 deletions.
2 changes: 2 additions & 0 deletions packages/icon/src/vaadin-icon.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,8 @@ declare class Icon extends ThemableMixin(ElementMixin(ControllerMixin(HTMLElemen
* values provided by the corresponding `vaadin-iconset` element.
*
* See also [`name`](#/elements/vaadin-iconset#property-name) property of `vaadin-iconset`.
*
* @attr {string} icon
*/
icon: string | null;

Expand Down
4 changes: 4 additions & 0 deletions packages/icon/src/vaadin-icon.js
Original file line number Diff line number Diff line change
Expand Up @@ -108,9 +108,13 @@ class Icon extends ThemableMixin(ElementMixin(ControllerMixin(PolymerElement)))
* values provided by the corresponding `vaadin-iconset` element.
*
* See also [`name`](#/elements/vaadin-iconset#property-name) property of `vaadin-iconset`.
*
* @attr {string} icon
* @type {string}
*/
icon: {
type: String,
reflectToAttribute: true,
observer: '__iconChanged',
},

Expand Down
7 changes: 7 additions & 0 deletions packages/icon/test/icon.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,13 @@ describe('vaadin-icon', () => {
svgElement = icon.shadowRoot.querySelector('svg');
});

it('should reflect the icon as an attribute', () => {
icons.forEach((svgIcon) => {
icon.icon = svgIcon.getAttribute('id');
expect(icon.getAttribute('icon')).to.equal(icon.icon);
});
});

it('should render icon from the iconset', () => {
icons.forEach((svgIcon) => {
icon.icon = svgIcon.getAttribute('id');
Expand Down

0 comments on commit 0a9e65b

Please sign in to comment.