You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+10-2Lines changed: 10 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -28,9 +28,9 @@ It uses standard JavaScript [Tagged Templates] and works in [all modern browsers
28
28
29
29
The syntax you write when using HTM is as close as possible to JSX:
30
30
31
-
- Spread props: `<div ...${props}>`
31
+
- Spread props: `<div ...${props}>` instead of `<div {...props}>`
32
32
- Self-closing tags: `<div />`
33
-
- Components: `<${Foo}>`_(where `Foo` is a component reference)_
33
+
- Components: `<${Foo}>`instead of `<Foo>`_(where `Foo` is a component reference)_
34
34
- Boolean attributes: `<div draggable />`
35
35
36
36
@@ -153,6 +153,14 @@ console.log(html`
153
153
// ]
154
154
```
155
155
156
+
### Caching
157
+
158
+
The default build of `htm` caches template strings, which means that it can return the same Javascript object at multiple points in the tree. If you don't want this behaviour, you have three options:
159
+
160
+
* Change your `h` function to copy nodes when needed.
161
+
* Add the code `this[0] = 3;` at the beginning of your `h` function, which disables caching of created elements.
162
+
* Use `htm/mini`, which disables caching by default.
163
+
156
164
## Example
157
165
158
166
Curious to see what it all looks like? Here's a working app!
0 commit comments