Merge pull request #948 from jcperea/feat/allow-custom-icon-manager

feat(icon): allow custom iconManager
This commit is contained in:
Joren Broekema 2020-12-03 11:53:49 +01:00 committed by GitHub
commit 0fbdf5a8bf
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 11 additions and 1 deletions

View file

@ -0,0 +1,5 @@
---
'@lion/icon': minor
---
Allow setting a custom icon manager, which is important if you as a subclasser are managing your singletons.

View file

@ -161,6 +161,11 @@ export class LionIcon extends LitElement {
} }
} }
// eslint-disable-next-line class-methods-use-this
get _iconManager() {
return icons;
}
/** /**
* @param {string} prevIconId * @param {string} prevIconId
*/ */
@ -172,7 +177,7 @@ export class LionIcon extends LitElement {
} }
} else { } else {
const iconIdBeforeResolve = this.iconId; const iconIdBeforeResolve = this.iconId;
const svg = await icons.resolveIconForId(iconIdBeforeResolve); const svg = await this._iconManager.resolveIconForId(iconIdBeforeResolve);
// update SVG if it did not change in the meantime to avoid race conditions // update SVG if it did not change in the meantime to avoid race conditions
if (this.iconId === iconIdBeforeResolve) { if (this.iconId === iconIdBeforeResolve) {