Skip to content

Commit 783dcd9

Browse files
committed
update
1 parent 4c2276e commit 783dcd9

1 file changed

Lines changed: 17 additions & 7 deletions

File tree

  • src/routes/reference/jsx-attributes

src/routes/reference/jsx-attributes/use.mdx

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -25,21 +25,21 @@ description: >-
2525
```ts
2626
type Accessor<T> = () => T;
2727

28-
function directive(element: HTMLElement, accessor: Accessor<any>): void;
28+
function directive(element: Element, accessor: Accessor<any>): void;
2929
```
3030

3131
## Value
3232

3333
- **Type:** directive argument
3434

35-
Value exposed to the directive through its accessor.
35+
Value exposed to the directive through an accessor.
36+
When no explicit value is passed, the accessor returns `true`.
3637

3738
## Behavior
3839

39-
- `use:name={value}` calls the directive named `name` with the element and an accessor for `value`.
40-
- Directive functions run during rendering before the element is connected to the DOM.
41-
- Directives only work on native elements, including custom elements.
42-
- Directives are not forwarded through user-defined components.
40+
- The compiler lowers `use:name={value}` to a directive helper call with the element and an accessor for `value`. Without an explicit value, the accessor returns `true`.
41+
- The directive runs during rendering before the element is connected to the DOM.
42+
- `use:*` works only on native elements, including custom elements, and is not forwarded through user-defined components.
4343

4444
## Examples
4545

@@ -58,5 +58,15 @@ const [name, setName] = createSignal("");
5858
```
5959

6060
:::note
61-
When using TypeScript, custom directives may require extending Solid's JSX directive typings.
61+
When using TypeScript, custom directives may require extending Solid's JSX directive typings:
62+
63+
```ts
64+
declare module "solid-js" {
65+
namespace JSX {
66+
interface Directives {
67+
model: [Accessor<string>, Setter<string>];
68+
}
69+
}
70+
}
71+
```
6272
:::

0 commit comments

Comments
 (0)