Skip to content

Commit 26f6e8e

Browse files
authored
hidden attribute without '?' prefix doesn't work
1 parent 59af258 commit 26f6e8e

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

packages/lit-dev-content/site/articles/article/lit-for-polymer-users.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -577,10 +577,10 @@ When migrating a Polymer `dom-if` to Lit, you have several choices:
577577

578578
- Use a simple JavaScript conditional. Lit removes and discards the conditional DOM when a condition changes to falsy. `dom-if` does the same thing if you set the `restamp` property to `true`.
579579

580-
- Use the standard `hidden` attribute to hide the content without removing it from the page.
580+
- Use the standard `hidden` attribute to hide the content without removing it from the page. Note the use here of the `?` prefix that causes boolean attributes to be added or removed rather than simply set (because `hidden="false"` is still hidden).
581581

582582
```html
583-
<header hidden=${this.headerHidden}>
583+
<header ?hidden=${this.headerHidden}>
584584
```
585585

586586
This is quite lightweight. However, the DOM is created on first render even if the condition is false.

0 commit comments

Comments
 (0)