@solidjs/router 0.4.3 → 0.5.0

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.
package/README.md CHANGED
@@ -98,7 +98,7 @@ export default function App() {
98
98
 
99
99
  3. Lazy-load route components
100
100
 
101
- This way, the `Users` and `Home` components will only be loaded if you're navigating to `/users` or `/home`, respectively.
101
+ This way, the `Users` and `Home` components will only be loaded if you're navigating to `/users` or `/`, respectively.
102
102
 
103
103
  ```jsx
104
104
  import { lazy } from "solid-js";
@@ -120,11 +120,11 @@ export default function App() {
120
120
 
121
121
  ## Create Links to Your Routes
122
122
 
123
- Use the `Link` component to create an anchor tag that takes you to a route:
123
+ Use the `A` component to create an anchor tag that takes you to a route:
124
124
 
125
125
  ```jsx
126
126
  import { lazy } from "solid-js";
127
- import { Routes, Route, Link } from "@solidjs/router"
127
+ import { Routes, Route, A } from "@solidjs/router"
128
128
  const Users = lazy(() => import("./pages/Users"));
129
129
  const Home = lazy(() => import("./pages/Home"));
130
130
 
@@ -132,8 +132,8 @@ export default function App() {
132
132
  return <>
133
133
  <h1>My Site with Lots of Pages</h1>
134
134
  <nav>
135
- <Link href="/about">About</Link>
136
- <Link href="/">Home</Link>
135
+ <A href="/about">About</A>
136
+ <A href="/">Home</A>
137
137
  </nav>
138
138
  <Routes>
139
139
  <Route path="/users" component={Users} />
@@ -144,33 +144,21 @@ export default function App() {
144
144
  }
145
145
  ```
146
146
 
147
- If you use `NavLink` instead of `Link`, the anchor tag will have an `active` class if its href matches the current location, and `inactive` otherwise. **Note:** By default matching includes locations that are descendents (eg. href `/users` matches locations `/users` and `/users/123`), use the boolean `end` prop to prevent matching these. This is particularly useful for links to the root route `/` which would match everything.
147
+ The `<A>` tag also has an `active` class if its href matches the current location, and `inactive` otherwise. **Note:** By default matching includes locations that are descendents (eg. href `/users` matches locations `/users` and `/users/123`), use the boolean `end` prop to prevent matching these. This is particularly useful for links to the root route `/` which would match everything.
148
148
 
149
- Both of these components have these props:
150
149
 
151
150
  | prop | type | description |
152
151
  |----------|---------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
153
152
  | href | string | The path of the route to navigate to. This will be resolved relative to the route that the link is in, but you can preface it with `/` to refer back to the root. |
154
153
  | noScroll | boolean | If true, turn off the default behavior of scrolling to the top of the new page |
155
154
  | replace | boolean | If true, don't add a new entry to the browser history. (By default, the new page will be added to the browser history, so pressing the back button will take you to the previous route.) |
156
- | state | unknown | [Push this value](https://developer.mozilla.org/en-US/docs/Web/API/History/pushState) to the history stack when navigating |
157
-
158
-
159
- `NavLink` additionally has:
160
-
161
- | prop | type | description |
162
- |----------|---------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
155
+ | state | unknown | [Push this value](https://developer.mozilla.org/en-US/docs/Web/API/History/pushState) to the history stack when navigating | |
163
156
  | inactiveClass | string | The class to show when the link is inactive (when the current location doesn't match the link) |
164
157
  | activeClass | string | The class to show when the link is active |
165
158
  | end | boolean | If `true`, only considers the link to be active when the curent location matches the `href` exactly; if `false`, check if the current location _starts with_ `href` |
166
159
 
167
-
168
-
169
-
170
- If you have a same-domain path that you want to link to _without_ going through the router, set `rel="external"` on the link component.
171
-
172
160
  ### The Navigate Component
173
- Solid Router provides a `Navigate` component that works similarly to `Link` and `NavLink`, but it will _immediately_ navigate to the provided path as soon as the component is rendered. It also uses the `href` prop, but you have the additional option of passing a function to `href` that returns a path to navigate to:
161
+ Solid Router provides a `Navigate` component that works similarly to `A`, but it will _immediately_ navigate to the provided path as soon as the component is rendered. It also uses the `href` prop, but you have the additional option of passing a function to `href` that returns a path to navigate to:
174
162
 
175
163
  ```jsx
176
164
  function getPath ({navigate, location}) {
@@ -180,9 +168,7 @@ function getPath ({navigate, location}) {
180
168
  }
181
169
 
182
170
  //Navigating to /redirect will redirect you to the result of getPath
183
- <Route path="/redirect">
184
- <Navigate href={getPath}/>
185
- </Route>
171
+ <Route path="/redirect" element={<Navigate href={getPath}/>}/>
186
172
  ```
187
173
 
188
174
  ## Dynamic Routes
@@ -198,7 +184,7 @@ const Home = lazy(() => import("./pages/Home"));
198
184
 
199
185
  export default function App() {
200
186
  return <>
201
- <h1>My Site with Lots of Pages<h1/>
187
+ <h1>My Site with Lots of Pages</h1>
202
188
  <Routes>
203
189
  <Route path="/users" component={Users} />
204
190
  <Route path="/users/:id" component={User} />
@@ -224,7 +210,7 @@ export default function User () {
224
210
 
225
211
  const [userData] = createResource(() => params.id, fetchUser);
226
212
 
227
- return <a href={userData.twitter}>{userData.name}</a>
213
+ return <A href={userData.twitter}>{userData.name}</A>
228
214
  }
229
215
  ```
230
216
 
@@ -273,9 +259,9 @@ To do this, create a function that fetches and returns the data using `createRes
273
259
  ```js
274
260
  import { lazy } from "solid-js";
275
261
  import { Route } from "@solidjs/router";
276
- import { fetchUser } ...
262
+ import { fetchUser } ...
277
263
 
278
- const User = lazy(() => import("/pages/users/[id].js"));
264
+ const User = lazy(() => import("./pages/users/[id].js"));
279
265
 
280
266
  //Data function
281
267
  function UserData({params, location, navigate, data}) {
@@ -361,7 +347,7 @@ function PageWrapper () {
361
347
  return <div>
362
348
  <h1> We love our users! </h1>
363
349
  <Outlet/>
364
- <Link href="/">Back Home</Link>
350
+ <A href="/">Back Home</A>
365
351
  </div>
366
352
  }
367
353
 
@@ -401,7 +387,7 @@ You don't have to use JSX to set up your routes; you can pass an object directly
401
387
  ```jsx
402
388
  import { lazy } from "solid-js";
403
389
  import { render } from "solid-js/web";
404
- import { Router, useRoutes, Link } from "@solidjs/router";
390
+ import { Router, useRoutes, A } from "@solidjs/router";
405
391
 
406
392
  const routes = [
407
393
  {
@@ -432,12 +418,12 @@ function App() {
432
418
  return (
433
419
  <>
434
420
  <h1>Awesome Site</h1>
435
- <Link class="nav" href="/">
421
+ <A class="nav" href="/">
436
422
  Home
437
- </Link>
438
- <Link class="nav" href="/users">
423
+ </A>
424
+ <A class="nav" href="/users">
439
425
  Users
440
- </Link>
426
+ </A>
441
427
  <Routes />
442
428
  </>
443
429
  );
@@ -6,6 +6,7 @@ declare module "solid-js" {
6
6
  state?: string;
7
7
  noScroll?: boolean;
8
8
  replace?: boolean;
9
+ link?: boolean;
9
10
  }
10
11
  }
11
12
  }
@@ -27,7 +28,7 @@ export interface RoutesProps {
27
28
  children: JSX.Element;
28
29
  }
29
30
  export declare const Routes: (props: RoutesProps) => JSX.Element;
30
- export declare const useRoutes: (routes: RouteDefinition | RouteDefinition[], base?: string | undefined) => () => JSX.Element;
31
+ export declare const useRoutes: (routes: RouteDefinition | RouteDefinition[], base?: string) => () => JSX.Element;
31
32
  export declare type RouteProps = {
32
33
  path: string | string[];
33
34
  children?: JSX.Element;
@@ -42,19 +43,17 @@ export declare type RouteProps = {
42
43
  });
43
44
  export declare const Route: (props: RouteProps) => JSX.Element;
44
45
  export declare const Outlet: () => JSX.Element;
45
- export interface LinkProps extends Omit<JSX.AnchorHTMLAttributes<HTMLAnchorElement>, "state"> {
46
+ export interface AnchorProps extends Omit<JSX.AnchorHTMLAttributes<HTMLAnchorElement>, "state"> {
46
47
  href: string;
47
48
  replace?: boolean;
48
49
  noScroll?: boolean;
49
50
  state?: unknown;
50
- }
51
- export declare function Link(props: LinkProps): JSX.Element;
52
- export interface NavLinkProps extends LinkProps {
53
51
  inactiveClass?: string;
54
52
  activeClass?: string;
55
53
  end?: boolean;
56
54
  }
57
- export declare function NavLink(props: NavLinkProps): JSX.Element;
55
+ export declare function A(props: AnchorProps): JSX.Element;
56
+ export { A as Link, A as NavLink, AnchorProps as LinkProps, AnchorProps as NavLinkProps };
58
57
  export interface NavigateProps {
59
58
  href: ((args: {
60
59
  navigate: Navigator;
@@ -54,7 +54,7 @@ export const Routes = (props) => {
54
54
  return next;
55
55
  }));
56
56
  return (<Show when={routeStates() && root}>
57
- {route => <RouteContextObj.Provider value={route}>{route.outlet()}</RouteContextObj.Provider>}
57
+ {((route) => (<RouteContextObj.Provider value={route}>{route.outlet()}</RouteContextObj.Provider>))}
58
58
  </Show>);
59
59
  };
60
60
  export const useRoutes = (routes, base) => {
@@ -71,36 +71,31 @@ export const Route = (props) => {
71
71
  export const Outlet = () => {
72
72
  const route = useRoute();
73
73
  return (<Show when={route.child}>
74
- {child => <RouteContextObj.Provider value={child}>{child.outlet()}</RouteContextObj.Provider>}
74
+ {((child) => (<RouteContextObj.Provider value={child}>{child.outlet()}</RouteContextObj.Provider>))}
75
75
  </Show>);
76
76
  };
77
- function LinkBase(props) {
78
- const [, rest] = splitProps(props, ["children", "to", "href", "state"]);
79
- const href = useHref(() => props.to);
80
- return (<a {...rest} href={href() || props.href} state={JSON.stringify(props.state)}>
81
- {props.children}
82
- </a>);
83
- }
84
- export function Link(props) {
85
- const to = useResolvedPath(() => props.href);
86
- return <LinkBase {...props} to={to()}/>;
87
- }
88
- export function NavLink(props) {
77
+ export function A(props) {
89
78
  props = mergeProps({ inactiveClass: "inactive", activeClass: "active" }, props);
90
- const [, rest] = splitProps(props, ["activeClass", "inactiveClass", "end"]);
91
- const location = useLocation();
79
+ const [, rest] = splitProps(props, ["href", "state", "activeClass", "inactiveClass", "end"]);
92
80
  const to = useResolvedPath(() => props.href);
81
+ const href = useHref(to);
82
+ const location = useLocation();
93
83
  const isActive = createMemo(() => {
94
84
  const to_ = to();
95
- if (to_ === undefined) {
85
+ if (to_ === undefined)
96
86
  return false;
97
- }
98
87
  const path = to_.split(/[?#]/, 1)[0].toLowerCase();
99
88
  const loc = location.pathname.toLowerCase();
100
89
  return props.end ? path === loc : loc.startsWith(path);
101
90
  });
102
- return (<LinkBase {...rest} to={to()} classList={{ [props.inactiveClass]: !isActive(), [props.activeClass]: isActive(), ...rest.classList }} aria-current={isActive() ? "page" : undefined}/>);
91
+ return (<a link {...rest} href={href() || props.href} state={JSON.stringify(props.state)} classList={{
92
+ [props.inactiveClass]: !isActive(),
93
+ [props.activeClass]: isActive(),
94
+ ...rest.classList
95
+ }} aria-current={isActive() ? "page" : undefined}/>);
103
96
  }
97
+ // deprecated alias exports
98
+ export { A as Link, A as NavLink };
104
99
  export function Navigate(props) {
105
100
  const navigate = useNavigate();
106
101
  const location = useLocation();
package/dist/index.js CHANGED
@@ -1,5 +1,5 @@
1
- import { isServer, delegateEvents, createComponent as createComponent$1, mergeProps as mergeProps$1, spread, insert, effect, setAttribute, template } from 'solid-js/web';
2
- import { createSignal, onCleanup, runWithOwner, createMemo, getOwner, createContext, useContext, untrack, useTransition, on, resetErrorBoundaries, createRenderEffect, createComponent, children, createRoot, Show, mergeProps, splitProps } from 'solid-js';
1
+ import { isServer, delegateEvents, createComponent as createComponent$1, spread, effect, setAttribute, classList, template } from 'solid-js/web';
2
+ import { createSignal, onCleanup, getOwner, runWithOwner, createMemo, createContext, useContext, untrack, createRenderEffect, createComponent, on, startTransition, resetErrorBoundaries, children, createRoot, Show, mergeProps, splitProps } from 'solid-js';
3
3
 
4
4
  function bindEvent(target, type, handler) {
5
5
  target.addEventListener(type, handler);
@@ -307,10 +307,9 @@ const useSearchParams = () => {
307
307
 
308
308
  const setSearchParams = (params, options) => {
309
309
  const searchString = untrack(() => mergeSearchString(location.search, params));
310
- navigate(searchString, {
310
+ navigate(location.pathname + searchString, {
311
311
  scroll: false,
312
- ...options,
313
- resolve: true
312
+ ...options
314
313
  });
315
314
  };
316
315
 
@@ -485,7 +484,18 @@ function createRouterContext(integration, base = "", data, out) {
485
484
  });
486
485
  }
487
486
 
488
- const [isRouting, start] = useTransition();
487
+ const [isRouting, setIsRouting] = createSignal(false);
488
+
489
+ const start = async callback => {
490
+ setIsRouting(true);
491
+
492
+ try {
493
+ await startTransition(callback);
494
+ } finally {
495
+ setIsRouting(false);
496
+ }
497
+ };
498
+
489
499
  const [reference, setReference] = createSignal(source().value);
490
500
  const [state, setState] = createSignal(source().state);
491
501
  const location = createLocation(reference, state);
@@ -624,21 +634,15 @@ function createRouterContext(integration, base = "", data, out) {
624
634
  });
625
635
 
626
636
  if (!isServer) {
627
- function isSvg(el) {
628
- return el.namespaceURI === "http://www.w3.org/2000/svg";
629
- }
630
-
631
637
  function handleAnchorClick(evt) {
632
638
  if (evt.defaultPrevented || evt.button !== 0 || evt.metaKey || evt.altKey || evt.ctrlKey || evt.shiftKey) return;
633
639
  const a = evt.composedPath().find(el => el instanceof Node && el.nodeName.toUpperCase() === "A");
634
- if (!a) return;
635
- const svg = isSvg(a);
636
- const href = svg ? a.href.baseVal : a.href;
637
- const target = svg ? a.target.baseVal : a.target;
638
- if (target || !href && !a.hasAttribute("state")) return;
640
+ if (!a || !a.hasAttribute("link")) return;
641
+ const href = a.href;
642
+ if (a.target || !href && !a.hasAttribute("state")) return;
639
643
  const rel = (a.getAttribute("rel") || "").split(/\s+/);
640
644
  if (a.hasAttribute("download") || rel && rel.includes("external")) return;
641
- const url = svg ? new URL(href, document.baseURI) : new URL(href);
645
+ const url = new URL(href);
642
646
  const pathname = urlDecode(url.pathname);
643
647
  if (url.origin !== window.location.origin || basePath && pathname && !pathname.toLowerCase().startsWith(basePath.toLowerCase())) return;
644
648
  const to = parsePath(pathname + urlDecode(url.search, true) + urlDecode(url.hash));
@@ -719,7 +723,7 @@ function createRouteContext(router, parent, child, match) {
719
723
  return route;
720
724
  }
721
725
 
722
- const _tmpl$ = /*#__PURE__*/template(`<a></a>`, 2);
726
+ const _tmpl$ = /*#__PURE__*/template(`<a link></a>`, 2);
723
727
  const Router = props => {
724
728
  const {
725
729
  source,
@@ -843,80 +847,52 @@ const Outlet = () => {
843
847
  })
844
848
  });
845
849
  };
846
-
847
- function LinkBase(props) {
848
- const [, rest] = splitProps(props, ["children", "to", "href", "state"]);
849
- const href = useHref(() => props.to);
850
- return (() => {
851
- const _el$ = _tmpl$.cloneNode(true);
852
-
853
- spread(_el$, rest, false, true);
854
-
855
- insert(_el$, () => props.children);
856
-
857
- effect(_p$ => {
858
- const _v$ = href() || props.href,
859
- _v$2 = JSON.stringify(props.state);
860
-
861
- _v$ !== _p$._v$ && setAttribute(_el$, "href", _p$._v$ = _v$);
862
- _v$2 !== _p$._v$2 && setAttribute(_el$, "state", _p$._v$2 = _v$2);
863
- return _p$;
864
- }, {
865
- _v$: undefined,
866
- _v$2: undefined
867
- });
868
-
869
- return _el$;
870
- })();
871
- }
872
-
873
- function Link(props) {
874
- const to = useResolvedPath(() => props.href);
875
- return createComponent$1(LinkBase, mergeProps$1(props, {
876
- get to() {
877
- return to();
878
- }
879
-
880
- }));
881
- }
882
- function NavLink(props) {
850
+ function A(props) {
883
851
  props = mergeProps({
884
852
  inactiveClass: "inactive",
885
853
  activeClass: "active"
886
854
  }, props);
887
- const [, rest] = splitProps(props, ["activeClass", "inactiveClass", "end"]);
888
- const location = useLocation();
855
+ const [, rest] = splitProps(props, ["href", "state", "activeClass", "inactiveClass", "end"]);
889
856
  const to = useResolvedPath(() => props.href);
857
+ const href = useHref(to);
858
+ const location = useLocation();
890
859
  const isActive = createMemo(() => {
891
860
  const to_ = to();
892
-
893
- if (to_ === undefined) {
894
- return false;
895
- }
896
-
861
+ if (to_ === undefined) return false;
897
862
  const path = to_.split(/[?#]/, 1)[0].toLowerCase();
898
863
  const loc = location.pathname.toLowerCase();
899
864
  return props.end ? path === loc : loc.startsWith(path);
900
865
  });
901
- return createComponent$1(LinkBase, mergeProps$1(rest, {
902
- get to() {
903
- return to();
904
- },
866
+ return (() => {
867
+ const _el$ = _tmpl$.cloneNode(true);
905
868
 
906
- get classList() {
907
- return {
869
+ spread(_el$, rest, false, false);
870
+
871
+ effect(_p$ => {
872
+ const _v$ = href() || props.href,
873
+ _v$2 = JSON.stringify(props.state),
874
+ _v$3 = {
908
875
  [props.inactiveClass]: !isActive(),
909
876
  [props.activeClass]: isActive(),
910
877
  ...rest.classList
911
- };
912
- },
878
+ },
879
+ _v$4 = isActive() ? "page" : undefined;
913
880
 
914
- get ["aria-current"]() {
915
- return isActive() ? "page" : undefined;
916
- }
881
+ _v$ !== _p$._v$ && setAttribute(_el$, "href", _p$._v$ = _v$);
882
+ _v$2 !== _p$._v$2 && setAttribute(_el$, "state", _p$._v$2 = _v$2);
883
+ _p$._v$3 = classList(_el$, _v$3, _p$._v$3);
884
+ _v$4 !== _p$._v$4 && setAttribute(_el$, "aria-current", _p$._v$4 = _v$4);
885
+ return _p$;
886
+ }, {
887
+ _v$: undefined,
888
+ _v$2: undefined,
889
+ _v$3: undefined,
890
+ _v$4: undefined
891
+ });
917
892
 
918
- }));
919
- }
893
+ return _el$;
894
+ })();
895
+ } // deprecated alias exports
920
896
  function Navigate(props) {
921
897
  const navigate = useNavigate();
922
898
  const location = useLocation();
@@ -935,4 +911,4 @@ function Navigate(props) {
935
911
  return null;
936
912
  }
937
913
 
938
- export { Link, NavLink, Navigate, Outlet, Route, Router, Routes, mergeSearchString as _mergeSearchString, createIntegration, hashIntegration, normalizeIntegration, pathIntegration, staticIntegration, useHref, useIsRouting, useLocation, useMatch, useNavigate, useParams, useResolvedPath, useRouteData, useRoutes, useSearchParams };
914
+ export { A, A as Link, A as NavLink, Navigate, Outlet, Route, Router, Routes, mergeSearchString as _mergeSearchString, createIntegration, hashIntegration, normalizeIntegration, pathIntegration, staticIntegration, useHref, useIsRouting, useLocation, useMatch, useNavigate, useParams, useResolvedPath, useRouteData, useRoutes, useSearchParams };
package/dist/routing.d.ts CHANGED
@@ -13,7 +13,7 @@ export declare const useMatch: (path: () => string) => Accessor<import("./types"
13
13
  export declare const useParams: <T extends Params>() => T;
14
14
  declare type MaybeReturnType<T> = T extends (...args: any) => infer R ? R : T;
15
15
  export declare const useRouteData: <T>() => MaybeReturnType<T>;
16
- export declare const useSearchParams: <T extends Params>() => [T, (params: SetParams, options?: Partial<NavigateOptions<unknown>> | undefined) => void];
16
+ export declare const useSearchParams: <T extends Params>() => [T, (params: SetParams, options?: Partial<NavigateOptions>) => void];
17
17
  export declare function createRoutes(routeDef: RouteDefinition, base?: string, fallback?: Component): Route[];
18
18
  export declare function createBranch(routes: Route[], index?: number): Branch;
19
19
  export declare function createBranches(routeDef: RouteDefinition | RouteDefinition[], base?: string, fallback?: Component, stack?: Route[], branches?: Branch[]): Branch[];
package/dist/routing.js CHANGED
@@ -1,4 +1,4 @@
1
- import { createComponent, createContext, createMemo, createRenderEffect, createSignal, on, onCleanup, untrack, useContext, useTransition, resetErrorBoundaries } from "solid-js";
1
+ import { createComponent, createContext, createMemo, createRenderEffect, createSignal, on, onCleanup, untrack, useContext, startTransition, resetErrorBoundaries } from "solid-js";
2
2
  import { isServer, delegateEvents } from "solid-js/web";
3
3
  import { normalizeIntegration } from "./integration";
4
4
  import { createMemoObject, extractSearchParams, invariant, resolvePath, createMatcher, joinPaths, scoreRoute, mergeSearchString, urlDecode, expandOptionals } from "./utils";
@@ -34,7 +34,7 @@ export const useSearchParams = () => {
34
34
  const navigate = useNavigate();
35
35
  const setSearchParams = (params, options) => {
36
36
  const searchString = untrack(() => mergeSearchString(location.search, params));
37
- navigate(searchString, { scroll: false, ...options, resolve: true });
37
+ navigate(location.pathname + searchString, { scroll: false, ...options });
38
38
  };
39
39
  return [location.query, setSearchParams];
40
40
  };
@@ -179,7 +179,16 @@ export function createRouterContext(integration, base = "", data, out) {
179
179
  else if (basePath && !source().value) {
180
180
  setSource({ value: basePath, replace: true, scroll: false });
181
181
  }
182
- const [isRouting, start] = useTransition();
182
+ const [isRouting, setIsRouting] = createSignal(false);
183
+ const start = async (callback) => {
184
+ setIsRouting(true);
185
+ try {
186
+ await startTransition(callback);
187
+ }
188
+ finally {
189
+ setIsRouting(false);
190
+ }
191
+ };
183
192
  const [reference, setReference] = createSignal(source().value);
184
193
  const [state, setState] = createSignal(source().state);
185
194
  const location = createLocation(reference, state);
@@ -292,9 +301,6 @@ export function createRouterContext(integration, base = "", data, out) {
292
301
  });
293
302
  });
294
303
  if (!isServer) {
295
- function isSvg(el) {
296
- return el.namespaceURI === "http://www.w3.org/2000/svg";
297
- }
298
304
  function handleAnchorClick(evt) {
299
305
  if (evt.defaultPrevented ||
300
306
  evt.button !== 0 ||
@@ -306,17 +312,15 @@ export function createRouterContext(integration, base = "", data, out) {
306
312
  const a = evt
307
313
  .composedPath()
308
314
  .find(el => el instanceof Node && el.nodeName.toUpperCase() === "A");
309
- if (!a)
315
+ if (!a || !a.hasAttribute("link"))
310
316
  return;
311
- const svg = isSvg(a);
312
- const href = svg ? a.href.baseVal : a.href;
313
- const target = svg ? a.target.baseVal : a.target;
314
- if (target || (!href && !a.hasAttribute("state")))
317
+ const href = a.href;
318
+ if (a.target || (!href && !a.hasAttribute("state")))
315
319
  return;
316
320
  const rel = (a.getAttribute("rel") || "").split(/\s+/);
317
321
  if (a.hasAttribute("download") || (rel && rel.includes("external")))
318
322
  return;
319
- const url = svg ? new URL(href, document.baseURI) : new URL(href);
323
+ const url = new URL(href);
320
324
  const pathname = urlDecode(url.pathname);
321
325
  if (url.origin !== window.location.origin ||
322
326
  (basePath && pathname && !pathname.toLowerCase().startsWith(basePath.toLowerCase())))
package/package.json CHANGED
@@ -6,7 +6,7 @@
6
6
  "Ryan Turnquist"
7
7
  ],
8
8
  "license": "MIT",
9
- "version": "0.4.3",
9
+ "version": "0.5.0",
10
10
  "homepage": "https://github.com/solidjs/solid-router#readme",
11
11
  "repository": {
12
12
  "type": "git",
@@ -38,23 +38,24 @@
38
38
  "pretty": "prettier --write \"{src,test}/**/*.{ts,tsx}\""
39
39
  },
40
40
  "devDependencies": {
41
- "@babel/core": "^7.15.8",
42
- "@babel/preset-typescript": "^7.15.0",
43
- "@rollup/plugin-babel": "5.3.0",
44
- "@rollup/plugin-node-resolve": "13.0.5",
45
- "@types/jest": "^27.0.2",
46
- "@types/node": "^16.10.3",
47
- "babel-preset-solid": "^1.4.4",
48
- "jest": "^27.2.5",
49
- "prettier": "^2.5.1",
50
- "rollup": "^2.52.1",
41
+ "@babel/core": "^7.18.13",
42
+ "@babel/preset-typescript": "^7.18.6",
43
+ "@rollup/plugin-babel": "5.3.1",
44
+ "@rollup/plugin-node-resolve": "13.3.0",
45
+ "@types/jest": "^29.0.0",
46
+ "@types/node": "^18.7.14",
47
+ "babel-preset-solid": "^1.5.3",
48
+ "jest": "^29.0.1",
49
+ "jest-environment-jsdom": "^29.1.2",
50
+ "prettier": "^2.7.1",
51
+ "rollup": "^2.79.0",
51
52
  "rollup-plugin-terser": "^7.0.2",
52
53
  "solid-jest": "^0.2.0",
53
- "solid-js": "^1.4.4",
54
- "typescript": "^4.5.4"
54
+ "solid-js": "^1.5.3",
55
+ "typescript": "^4.8.2"
55
56
  },
56
57
  "peerDependencies": {
57
- "solid-js": "^1.3.5"
58
+ "solid-js": "^1.5.3"
58
59
  },
59
60
  "jest": {
60
61
  "preset": "solid-jest/preset/browser"