Skip to content

Commit 4ff7a1e

Browse files
committed
fix(icon): render nothing consistently when svg is null
1 parent 5f95212 commit 4ff7a1e

File tree

2 files changed

+13
-1
lines changed

2 files changed

+13
-1
lines changed

packages/icon/src/LionIcon.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ export class LionIcon extends LitElement {
8383
*/
8484
set svg(svg) {
8585
this.__svg = svg;
86-
if (svg === undefined) {
86+
if (svg === undefined || svg === null) {
8787
this._renderSvg(nothing);
8888
} else if (isPromise(svg)) {
8989
this._renderSvg(nothing); // show nothing before resolved

packages/icon/test/lion-icon.test.js

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -203,6 +203,18 @@ describe('lion-icon', () => {
203203
expect(el.innerHTML).to.equal('<!----><!---->'); // don't use lightDom.to.equal(''), it gives false positives
204204
});
205205

206+
it('does not render "null" if changed from valid input to null', async () => {
207+
const el = await fixture(
208+
html`
209+
<lion-icon .svg=${heartSvg}></lion-icon>
210+
`,
211+
);
212+
await el.updateComplete;
213+
el.svg = null;
214+
await el.updateComplete;
215+
expect(el.innerHTML).to.equal('<!----><!---->'); // don't use lightDom.to.equal(''), it gives false positives
216+
});
217+
206218
describe('race conditions with dynamic promisified icons', () => {
207219
async function prepareRaceCondition(...svgs) {
208220
const container = fixtureSync(`<div></div>`);

0 commit comments

Comments
 (0)