Skip to content

Commit c130f69

Browse files
authored
chore: add ifDefined to only add HTML attributes when prop values exist
1 parent 830a881 commit c130f69

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

packages/uikit-workshop/src/scripts/lit-components/pl-logo/pl-logo.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import { store } from '../../store.js'; // connect to redux
2+
import { ifDefined } from 'lit-html/directives/if-defined';
23
import { html } from 'lit-html';
34
import { customElement } from 'lit-element';
45
import { BaseLitComponent } from '../../components/base-component';
@@ -49,8 +50,8 @@ class Logo extends BaseLitComponent {
4950
alt=${this.altText || 'Pattern Lab Logo'}
5051
src=${imageSrc}
5152
class="pl-c-logo__img"
52-
width="${this.width}"
53-
height="${this.height}"
53+
width="${ifDefined(this.width)}"
54+
height="${ifDefined(this.height)}"
5455
/>
5556
${this.text && this.text !== ''
5657
? html`

0 commit comments

Comments
 (0)