@solidjs/router 0.14.4 → 0.14.6

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.
@@ -62,7 +62,7 @@ export function cache(fn, name) {
62
62
  const data = e && (e.router.data || (e.router.data = {}));
63
63
  if (data && key in data)
64
64
  return data[key];
65
- if (Array.isArray(dataOnly) && !dataOnly.includes(key)) {
65
+ if (Array.isArray(dataOnly) && !matchKey(key, dataOnly)) {
66
66
  data[key] = undefined;
67
67
  return Promise.resolve();
68
68
  }
@@ -49,7 +49,7 @@ export function setupNativeEvents(preload = true, explicitLinks = false, actionB
49
49
  resolve: false,
50
50
  replace: a.hasAttribute("replace"),
51
51
  scroll: !a.hasAttribute("noscroll"),
52
- state: state && JSON.parse(state)
52
+ state: state ? JSON.parse(state) : undefined
53
53
  });
54
54
  }
55
55
  function handleAnchorPreload(evt) {
package/dist/index.js CHANGED
@@ -132,12 +132,12 @@ function createMatcher(path, partial, matchFilters) {
132
132
  const matchFilter = s => matchFilters === undefined ? undefined : matchFilters[s];
133
133
  for (let i = 0; i < len; i++) {
134
134
  const segment = segments[i];
135
- const locSegment = locSegments[i];
136
135
  const dynamic = segment[0] === ":";
137
- const key = dynamic ? segment.slice(1) : segment;
136
+ const locSegment = dynamic ? locSegments[i] : locSegments[i].toLowerCase();
137
+ const key = dynamic ? segment.slice(1) : segment.toLowerCase();
138
138
  if (dynamic && matchSegment(locSegment, matchFilter(key))) {
139
139
  match.params[key] = locSegment;
140
- } else if (dynamic || !matchSegment(locSegment, segment)) {
140
+ } else if (dynamic || !matchSegment(locSegment, key)) {
141
141
  return null;
142
142
  }
143
143
  match.path += `/${locSegment}`;
@@ -154,9 +154,7 @@ function createMatcher(path, partial, matchFilters) {
154
154
  };
155
155
  }
156
156
  function matchSegment(input, filter) {
157
- const isEqual = s => s.localeCompare(input, undefined, {
158
- sensitivity: "base"
159
- }) === 0;
157
+ const isEqual = s => s === input;
160
158
  if (filter === undefined) {
161
159
  return true;
162
160
  } else if (typeof filter === "string") {
@@ -821,17 +819,6 @@ function dataOnly(event, routerState, branches) {
821
819
  function intercept([value, setValue], get, set) {
822
820
  return [get ? () => get(value()) : value, set ? v => setValue(set(v)) : setValue];
823
821
  }
824
- function querySelector(selector) {
825
- if (selector === "#") {
826
- return null;
827
- }
828
- // Guard against selector being an invalid CSS selector
829
- try {
830
- return document.querySelector(selector);
831
- } catch (e) {
832
- return null;
833
- }
834
- }
835
822
  function createRouter(config) {
836
823
  let ignore = false;
837
824
  const wrap = value => typeof value === "string" ? {
@@ -860,7 +847,7 @@ function bindEvent(target, type, handler) {
860
847
  return () => target.removeEventListener(type, handler);
861
848
  }
862
849
  function scrollToHash(hash, fallbackTop) {
863
- const el = querySelector(`#${hash}`);
850
+ const el = hash && document.getElementById(hash);
864
851
  if (el) {
865
852
  el.scrollIntoView();
866
853
  } else if (fallbackTop) {
@@ -939,7 +926,7 @@ function cache(fn, name) {
939
926
  if (dataOnly) {
940
927
  const data = e && (e.router.data || (e.router.data = {}));
941
928
  if (data && key in data) return data[key];
942
- if (Array.isArray(dataOnly) && !dataOnly.includes(key)) {
929
+ if (Array.isArray(dataOnly) && !matchKey(key, dataOnly)) {
943
930
  data[key] = undefined;
944
931
  return Promise.resolve();
945
932
  }
@@ -1225,7 +1212,7 @@ function setupNativeEvents(preload = true, explicitLinks = false, actionBase = "
1225
1212
  resolve: false,
1226
1213
  replace: a.hasAttribute("replace"),
1227
1214
  scroll: !a.hasAttribute("noscroll"),
1228
- state: state && JSON.parse(state)
1215
+ state: state ? JSON.parse(state) : undefined
1229
1216
  });
1230
1217
  }
1231
1218
  function handleAnchorPreload(evt) {
@@ -3,18 +3,6 @@ import { createRouterComponent } from "./components.jsx";
3
3
  function intercept([value, setValue], get, set) {
4
4
  return [get ? () => get(value()) : value, set ? (v) => setValue(set(v)) : setValue];
5
5
  }
6
- function querySelector(selector) {
7
- if (selector === "#") {
8
- return null;
9
- }
10
- // Guard against selector being an invalid CSS selector
11
- try {
12
- return document.querySelector(selector);
13
- }
14
- catch (e) {
15
- return null;
16
- }
17
- }
18
6
  export function createRouter(config) {
19
7
  let ignore = false;
20
8
  const wrap = (value) => (typeof value === "string" ? { value } : value);
@@ -43,7 +31,7 @@ export function bindEvent(target, type, handler) {
43
31
  return () => target.removeEventListener(type, handler);
44
32
  }
45
33
  export function scrollToHash(hash, fallbackTop) {
46
- const el = querySelector(`#${hash}`);
34
+ const el = hash && document.getElementById(hash);
47
35
  if (el) {
48
36
  el.scrollIntoView();
49
37
  }
package/dist/utils.js CHANGED
@@ -57,13 +57,13 @@ export function createMatcher(path, partial, matchFilters) {
57
57
  const matchFilter = (s) => matchFilters === undefined ? undefined : matchFilters[s];
58
58
  for (let i = 0; i < len; i++) {
59
59
  const segment = segments[i];
60
- const locSegment = locSegments[i];
61
60
  const dynamic = segment[0] === ":";
62
- const key = dynamic ? segment.slice(1) : segment;
61
+ const locSegment = dynamic ? locSegments[i] : locSegments[i].toLowerCase();
62
+ const key = dynamic ? segment.slice(1) : segment.toLowerCase();
63
63
  if (dynamic && matchSegment(locSegment, matchFilter(key))) {
64
64
  match.params[key] = locSegment;
65
65
  }
66
- else if (dynamic || !matchSegment(locSegment, segment)) {
66
+ else if (dynamic || !matchSegment(locSegment, key)) {
67
67
  return null;
68
68
  }
69
69
  match.path += `/${locSegment}`;
@@ -81,7 +81,7 @@ export function createMatcher(path, partial, matchFilters) {
81
81
  };
82
82
  }
83
83
  function matchSegment(input, filter) {
84
- const isEqual = (s) => s.localeCompare(input, undefined, { sensitivity: "base" }) === 0;
84
+ const isEqual = (s) => s === input;
85
85
  if (filter === undefined) {
86
86
  return true;
87
87
  }
package/package.json CHANGED
@@ -6,7 +6,7 @@
6
6
  "Ryan Turnquist"
7
7
  ],
8
8
  "license": "MIT",
9
- "version": "0.14.4",
9
+ "version": "0.14.6",
10
10
  "homepage": "https://github.com/solidjs/solid-router#readme",
11
11
  "repository": {
12
12
  "type": "git",