Merge pull request #948 from jcperea/feat/allow-custom-icon-manager
feat(icon): allow custom iconManager
This commit is contained in:
commit
0fbdf5a8bf
2 changed files with 11 additions and 1 deletions
5
.changeset/forty-buttons-occur.md
Normal file
5
.changeset/forty-buttons-occur.md
Normal 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.
|
||||||
|
|
@ -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) {
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue