Skip to content
This repository has been archived by the owner on Dec 19, 2024. It is now read-only.

Ensure _applyIcon is not called multiple times. Fixes #120 #121

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 14 additions & 7 deletions iron-icon.html
Original file line number Diff line number Diff line change
Expand Up @@ -183,13 +183,20 @@
this._iconset.removeIcon(this);
}
} else if (this._iconsetName && this._meta) {
this._iconset = /** @type {?Polymer.Iconset} */ (
this._meta.byKey(this._iconsetName));
if (this._iconset) {
this._iconset.applyIcon(this, this._iconName, this.theme);
this.unlisten(window, 'iron-iconset-added', '_updateIcon');
} else {
this.listen(window, 'iron-iconset-added', '_updateIcon');
// Since _updateIcon can be called multiple times, make sure we
// avoid cloning the SVG if the icon & theme haven't changed
if (this._iconName !== this._lastIconName ||

Choose a reason for hiding this comment

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

Can we introduce two constants right above for these inequality comparisons to increase readability? I’d suggest iconNameChanged and themeChanged

this.theme !== this._lastTheme) {
this._iconset = /** @type {?Polymer.Iconset} */ (
this._meta.byKey(this._iconsetName));
if (this._iconset) {
this._lastIconName = this._iconName;
this._lastTheme = this.theme;
this._iconset.applyIcon(this, this._iconName, this.theme);
this.unlisten(window, 'iron-iconset-added', '_updateIcon');
} else {
this.listen(window, 'iron-iconset-added', '_updateIcon');
}
}
}
} else {
Expand Down