fix(icon): render nothing consistently when svg is undefined
This commit is contained in:
parent
938e445781
commit
c62d3353a2
2 changed files with 13 additions and 1 deletions
|
|
@ -89,7 +89,7 @@ export class LionIcon extends LionLitElement {
|
||||||
* so make sure to have <svg focusable="false"> in svg files
|
* so make sure to have <svg focusable="false"> in svg files
|
||||||
*/
|
*/
|
||||||
_setSvg() {
|
_setSvg() {
|
||||||
this.innerHTML = this.svg;
|
this.innerHTML = this.svg ? this.svg : '';
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: find a better way to render dynamic icons without the need for unsafeHTML
|
// TODO: find a better way to render dynamic icons without the need for unsafeHTML
|
||||||
|
|
|
||||||
|
|
@ -149,4 +149,16 @@ describe('lion-icon', () => {
|
||||||
|
|
||||||
expect(el.children[0].id).to.equal('svg-heart');
|
expect(el.children[0].id).to.equal('svg-heart');
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('does not render "undefined" if changed from valid input to undefined', async () => {
|
||||||
|
const el = await fixture(
|
||||||
|
html`
|
||||||
|
<lion-icon .svg=${heartSvg}></lion-icon>
|
||||||
|
`,
|
||||||
|
);
|
||||||
|
await el.updateComplete;
|
||||||
|
el.svg = undefined;
|
||||||
|
await el.updateComplete;
|
||||||
|
expect(el.innerHTML).to.equal('');
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue