Improve docs

This commit is contained in:
Ben Croker 2025-03-12 18:57:12 -06:00
parent 2d1cf0ce54
commit d898f92cb9
No known key found for this signature in database
GPG Key ID: 09D799816F1CF332
2 changed files with 7 additions and 1 deletions

View File

@ -378,6 +378,12 @@ Show or hides an element based on whether an expression evaluates to `true` or `
<div data-show="$foo"></div>
```
To prevent flickering of the element before Datastar has processed the DOM, you can add a `display: none` style to the element to hide it initially.
```html
<div data-show="$foo" style="display: none"></div>
```
### `data-view-transition`
Sets the `view-transition-name` style attribute explicitly.

View File

@ -16,7 +16,7 @@ If, for some reason, you cannot escape unsafe user input, you should ignore it u
## Content Security Policy
When using a [Content Security Policy](https://developer.mozilla.org/en-US/docs/Web/HTTP/CSP) (CSP), `unsafe-eval` must be allowed for scripts, since Datastar evaluates expressions inline.
When using a [Content Security Policy](https://developer.mozilla.org/en-US/docs/Web/HTTP/CSP) (CSP), `unsafe-eval` must be allowed for scripts, since Datastar evaluates expressions using an [IIFE](https://developer.mozilla.org/en-US/docs/Glossary/IIFE) (Immediately Invoked Function Expression).
```html
<meta http-equiv="Content-Security-Policy"