@solidjs/router 0.14.5 → 0.14.7
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/dist/data/action.js +3 -0
- package/dist/data/events.js +1 -1
- package/dist/index.js +9 -19
- package/dist/routers/createRouter.js +1 -13
- package/dist/utils.js +4 -4
- package/package.json +1 -1
package/dist/data/action.js
CHANGED
package/dist/data/events.js
CHANGED
|
@@ -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
|
|
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
|
|
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,
|
|
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
|
|
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 =
|
|
850
|
+
const el = hash && document.getElementById(hash);
|
|
864
851
|
if (el) {
|
|
865
852
|
el.scrollIntoView();
|
|
866
853
|
} else if (fallbackTop) {
|
|
@@ -1070,6 +1057,9 @@ function useSubmissions(fn, filter) {
|
|
|
1070
1057
|
if (property === $TRACK) return subs();
|
|
1071
1058
|
if (property === "pending") return subs().some(sub => !sub.result);
|
|
1072
1059
|
return subs()[property];
|
|
1060
|
+
},
|
|
1061
|
+
has(_, property) {
|
|
1062
|
+
return property in subs();
|
|
1073
1063
|
}
|
|
1074
1064
|
});
|
|
1075
1065
|
}
|
|
@@ -1225,7 +1215,7 @@ function setupNativeEvents(preload = true, explicitLinks = false, actionBase = "
|
|
|
1225
1215
|
resolve: false,
|
|
1226
1216
|
replace: a.hasAttribute("replace"),
|
|
1227
1217
|
scroll: !a.hasAttribute("noscroll"),
|
|
1228
|
-
state: state
|
|
1218
|
+
state: state ? JSON.parse(state) : undefined
|
|
1229
1219
|
});
|
|
1230
1220
|
}
|
|
1231
1221
|
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 =
|
|
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
|
|
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,
|
|
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
|
|
84
|
+
const isEqual = (s) => s === input;
|
|
85
85
|
if (filter === undefined) {
|
|
86
86
|
return true;
|
|
87
87
|
}
|