-
Notifications
You must be signed in to change notification settings - Fork 17
Common gotchas
Kian (Hossein) Esmaeilpour edited this page Nov 22, 2019
·
4 revisions
-
For a
Boolean
property to be configurable from markup, it mustdefault
tofalse
. If it defaults to true, you cannot set it to false from markup, since the presence of the attribute, with or without a value, equates to true. This is the standard behavior for attributes in the web platform.If this behavior doesn't fit your use case, you can use a string-valued or number-valued attribute instead.
-
Create
text
type input:const content = text('content', '<h1>Content Title</h1>');
-
Set
escapeHTML
tofalse
inwithKnobs
decorator:.addDecorator(withKnobs({escapeHTML: false}))
-
Pass the variable like
html([content])
to parse the string inlit-html
:return html` <ts-card ?rtl="${rtl}" type="${type}" size="${size}" orientation="${orientation}"> ${html([content])} </ts-card> `;
-
If you set the value of an attribute like this:
const el = document.createElement('ts-list-item'); el.title = 'Sample title'; el.disabled = boolean('disabled', false);
then the changes wouldn't show up in the html!
-
If you want to dynamically generate template and having a event listener:
/* eslint-disable lit/no-template-bind */ return html` <button @click="${() => this.tabClickHandler(tab, index)}"></button> `; /* eslint-enable */