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
The `links action` intercepts click events on dom elements and upwardly navigate the dom tree until it reaches a link element and triggers a router navigation instead.
@@ -351,6 +370,27 @@ Note: Unlike use:link, use:links does not normalize link attributes (role, tabin
351
370
</div>
352
371
```
353
372
373
+
#### Links attachment
374
+
375
+
The `links attachment` intercepts click events on dom elements and upwardly navigate the dom tree until it reaches a link element and triggers a router navigation instead.
376
+
377
+
Similar to the `links action`, see the [links action](#links-action) for more information.
378
+
379
+
```svelte
380
+
<script lang="ts">
381
+
import { useLinks } from '@dvcol/svelte-simple-router/attachment';
* The `links action` intercepts click events on dom elements and upwardly navigate the dom tree until it reaches a link element and triggers a router navigation instead.
* The `links attachment` intercepts click events on dom elements and upwardly navigate the dom tree until it reaches a link element and triggers a router navigation instead.
9
+
*
10
+
* The links attachment will recognize a parent node as a router link if it satisfies any of the following conditions:
11
+
* - The element is an anchor element
12
+
* - The element has a `data-router-link` attribute
13
+
* - The element satisfies the `apply` selector function passed as argument
14
+
*
15
+
* When a node is recognized as a router link, the attachment will behave as the `link` attachment (all restrictions apply).
16
+
*
17
+
* Additionally:
18
+
* - The attachment requires either valid href or data-attributes to navigate.
19
+
* - Once the attachment reaches the host element or the `boundary` element (or selector function), it will stop evaluating the dom tree.
20
+
*
21
+
* Note: The attachment requires a router instance or the router context to be present in the component tree.
22
+
* Note: Unlike use:link, use:links does not normalize link attributes (role, tabindex, href).
0 commit comments