Merge pull request #276 from noventadev/fix/icon-throws-svg-null
Update LionIcon to no longer throw when svg is null
This commit is contained in:
commit
5c443349aa
2 changed files with 13 additions and 1 deletions
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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`
|
||||
<lion-icon .svg=${heartSvg}></lion-icon>
|
||||
`,
|
||||
);
|
||||
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(`<div></div>`);
|
||||
|
|
|
|||
Loading…
Reference in a new issue