From 4ff7a1e846301a88600b59426ccccec9e680ec96 Mon Sep 17 00:00:00 2001 From: Marcos Gil Date: Mon, 16 Sep 2019 19:51:01 +0200 Subject: [PATCH] fix(icon): render nothing consistently when svg is null --- packages/icon/src/LionIcon.js | 2 +- packages/icon/test/lion-icon.test.js | 12 ++++++++++++ 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/packages/icon/src/LionIcon.js b/packages/icon/src/LionIcon.js index 200a60460..3a36a28b3 100644 --- a/packages/icon/src/LionIcon.js +++ b/packages/icon/src/LionIcon.js @@ -83,7 +83,7 @@ export class LionIcon extends LitElement { */ set svg(svg) { this.__svg = svg; - if (svg === undefined) { + if (svg === undefined || svg === null) { this._renderSvg(nothing); } else if (isPromise(svg)) { this._renderSvg(nothing); // show nothing before resolved diff --git a/packages/icon/test/lion-icon.test.js b/packages/icon/test/lion-icon.test.js index 316c4db9b..ffb51c680 100644 --- a/packages/icon/test/lion-icon.test.js +++ b/packages/icon/test/lion-icon.test.js @@ -203,6 +203,18 @@ describe('lion-icon', () => { expect(el.innerHTML).to.equal(''); // don't use lightDom.to.equal(''), it gives false positives }); + it('does not render "null" if changed from valid input to null', async () => { + const el = await fixture( + html` + + `, + ); + await el.updateComplete; + el.svg = null; + await el.updateComplete; + expect(el.innerHTML).to.equal(''); // don't use lightDom.to.equal(''), it gives false positives + }); + describe('race conditions with dynamic promisified icons', () => { async function prepareRaceCondition(...svgs) { const container = fixtureSync(`
`);