-
Notifications
You must be signed in to change notification settings - Fork 12
Open
Description
Conditional attributes can be tough to work with.
Our current recommended practice is using Object.keys:
export default function MyElement ({ html, state }) {
const { attrs } = state
const disabled = Object.keys(attrs).includes('disabled')
? 'disabled'
: ''
return html`<button ${disabled}>I Can Haz?</button>`
}We should look into a helper to make this less cumbersome.
To keep in mind: there are attributes (e.g. many ARIA attributes) which are non-boolean.
Metadata
Metadata
Assignees
Labels
No labels