@symbo.ls/link 2.11.281 → 2.11.310

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/index.js +15 -10
  2. package/package.json +2 -2
package/index.js CHANGED
@@ -1,7 +1,7 @@
1
1
  'use strict'
2
2
 
3
3
  import { router as defaultRouter } from '@domql/router'
4
- import { isDefined } from '@domql/utils'
4
+ import { exec, isDefined } from '@domql/utils'
5
5
  import { Focusable } from '@symbo.ls/atoms'
6
6
 
7
7
  export const Link = {
@@ -28,9 +28,10 @@ export const Link = {
28
28
 
29
29
  export const RouterLink = {
30
30
  on: {
31
- click: (event, el) => {
31
+ click: (event, el, s) => {
32
32
  const { props, context: ctx } = el
33
- const { href, scrollToTop, stopPropagation } = props
33
+ const { href: h, scrollToTop, stopPropagation } = props
34
+ const href = exec(h, el, s)
34
35
  if (stopPropagation) event.stopPropagation()
35
36
  if (!href) return
36
37
  const { utils, snippets, routerOptions } = ctx
@@ -40,13 +41,17 @@ export const RouterLink = {
40
41
  href.includes('mailto:') ||
41
42
  href.includes('tel:')
42
43
  if (href && !linkIsExternal) {
43
- (snippets.router || utils.router || defaultRouter)(href, root, {}, {
44
- scrollToOptions: { behaviour: 'instant' },
45
- scrollToTop: isDefined(scrollToTop) ? scrollToTop : true,
46
- ...routerOptions,
47
- ...props.routerOptions
48
- })
49
- event.preventDefault()
44
+ try {
45
+ (snippets.router || utils.router || defaultRouter)(href, root, {}, {
46
+ scrollToOptions: { behaviour: 'instant' },
47
+ scrollToTop: isDefined(scrollToTop) ? scrollToTop : true,
48
+ ...routerOptions,
49
+ ...props.routerOptions
50
+ })
51
+ event.preventDefault()
52
+ } catch (e) {
53
+ console.warn(e)
54
+ }
50
55
  }
51
56
  }
52
57
  }
package/package.json CHANGED
@@ -1,9 +1,9 @@
1
1
  {
2
2
  "name": "@symbo.ls/link",
3
- "version": "2.11.281",
3
+ "version": "2.11.310",
4
4
  "main": "index.js",
5
5
  "license": "MIT",
6
- "gitHead": "ad7f8b95bf87b752026b0c402e032592e7747f72",
6
+ "gitHead": "3e774509842b471eda7cd8d34ea79bd8c70c79a9",
7
7
  "dependencies": {
8
8
  "@domql/router": "latest",
9
9
  "@symbo.ls/atoms": "latest"