@symbo.ls/link 2.11.257 → 2.11.281

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 +9 -5
  2. package/package.json +2 -2
package/index.js CHANGED
@@ -1,6 +1,7 @@
1
1
  'use strict'
2
2
 
3
3
  import { router as defaultRouter } from '@domql/router'
4
+ import { isDefined } from '@domql/utils'
4
5
  import { Focusable } from '@symbo.ls/atoms'
5
6
 
6
7
  export const Link = {
@@ -29,7 +30,8 @@ export const RouterLink = {
29
30
  on: {
30
31
  click: (event, el) => {
31
32
  const { props, context: ctx } = el
32
- const { href } = props
33
+ const { href, scrollToTop, stopPropagation } = props
34
+ if (stopPropagation) event.stopPropagation()
33
35
  if (!href) return
34
36
  const { utils, snippets, routerOptions } = ctx
35
37
  const root = el.__ref.__root
@@ -37,11 +39,13 @@ export const RouterLink = {
37
39
  href.includes('https://') ||
38
40
  href.includes('mailto:') ||
39
41
  href.includes('tel:')
40
- const options = props.routerOptions || routerOptions || {
41
- scrollToOptions: { behaviour: 'instant' }
42
- }
43
42
  if (href && !linkIsExternal) {
44
- (snippets.router || utils.router || defaultRouter)(href, root, {}, options)
43
+ (snippets.router || utils.router || defaultRouter)(href, root, {}, {
44
+ scrollToOptions: { behaviour: 'instant' },
45
+ scrollToTop: isDefined(scrollToTop) ? scrollToTop : true,
46
+ ...routerOptions,
47
+ ...props.routerOptions
48
+ })
45
49
  event.preventDefault()
46
50
  }
47
51
  }
package/package.json CHANGED
@@ -1,9 +1,9 @@
1
1
  {
2
2
  "name": "@symbo.ls/link",
3
- "version": "2.11.257",
3
+ "version": "2.11.281",
4
4
  "main": "index.js",
5
5
  "license": "MIT",
6
- "gitHead": "fee03ced348ded2839443d9636f6da28d9952465",
6
+ "gitHead": "ad7f8b95bf87b752026b0c402e032592e7747f72",
7
7
  "dependencies": {
8
8
  "@domql/router": "latest",
9
9
  "@symbo.ls/atoms": "latest"