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:
Joren Broekema 2019-09-17 07:46:43 -07:00 committed by GitHub
commit 5c443349aa
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 13 additions and 1 deletions

View file

@ -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

View file

@ -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>`);