@real-router/svelte 0.17.32 → 0.17.33
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/dom-utils/link-utils.js +54 -29
- package/package.json +2 -2
|
@@ -127,37 +127,62 @@ export function navigateWithHash(router, routeName, routeParams, routeSearch, ha
|
|
|
127
127
|
opts.hash = hash;
|
|
128
128
|
}
|
|
129
129
|
const current = router.getState();
|
|
130
|
-
//
|
|
131
|
-
//
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
130
|
+
// What the navigation gets — the caller's `routeSearch` unless the bypass
|
|
131
|
+
// below substitutes it (#1925).
|
|
132
|
+
let navigatedSearch = routeSearch;
|
|
133
|
+
if (current !== undefined) {
|
|
134
|
+
// ONE expression, asked ONCE and navigated with under the bypass (#1925).
|
|
135
|
+
// The predicate's answer is only as good as the value it answered ABOUT, so
|
|
136
|
+
// the two must be the same value — a second copy of this expression would
|
|
137
|
+
// let them drift apart with nothing to catch it. The name is what keeps
|
|
138
|
+
// them in agreement structurally rather than by convention.
|
|
139
|
+
const sameLocationSearch = routeSearch ?? current.search;
|
|
140
|
+
// "Does this link point at where we already are?" is a question the router
|
|
141
|
+
// owns, and asking it here by hand got two things wrong at once (#1555).
|
|
142
|
+
//
|
|
143
|
+
// The hand-rolled version compared with `Object.is` per key, so a link
|
|
144
|
+
// writing `routeSearch={{ page: "2" }}` never matched a state parsed from
|
|
145
|
+
// `?page=2`, where the value is the NUMBER 2 — the bypass silently did not
|
|
146
|
+
// fire, core rejected the navigation as SAME_STATES, and `<Link hash>`
|
|
147
|
+
// looked dead. The predicate carries the provenance-tolerant comparison
|
|
148
|
+
// (#1554) that makes the two forms equal because they print the same URL.
|
|
149
|
+
//
|
|
150
|
+
// It also compared the caller's whole `routeParams` bag against
|
|
151
|
+
// `state.params`, which stopped meaning anything once the channels split
|
|
152
|
+
// (#1548) — the predicate applies the channel rule instead of re-deriving
|
|
153
|
+
// it.
|
|
154
|
+
//
|
|
155
|
+
// `strictEquality: true` — a link to a PARENT route is a different
|
|
156
|
+
// location, so the hierarchical arm must not match. `ignoreQueryParams:
|
|
157
|
+
// false` — the query is part of the location here; ignoring it would fire
|
|
158
|
+
// the bypass across a real query change and let `force: true` smuggle it
|
|
159
|
+
// through as a hash change.
|
|
160
|
+
if (router.isActiveRoute(routeName, routeParams, sameLocationSearch, true, false)) {
|
|
161
|
+
const currentHash = current.context?.url
|
|
162
|
+
?.hash ?? "";
|
|
163
|
+
const newHash = hash ?? currentHash;
|
|
164
|
+
if (currentHash !== newHash) {
|
|
165
|
+
opts.force = true;
|
|
166
|
+
opts.hashChange = true;
|
|
167
|
+
// Reaching here means the predicate answered "this is where we already
|
|
168
|
+
// are, only the fragment differs", and `force` + `hashChange` announce
|
|
169
|
+
// exactly that. The bare `routeSearch` would say "no query" rather than
|
|
170
|
+
// "unchanged" — on `/docs?tab=api` a fragment link would land on
|
|
171
|
+
// `/docs`, moving the location it just announced as unmoved. Same slot,
|
|
172
|
+
// same conclusion as `scroll-spy.ts`, which re-navigates with both
|
|
173
|
+
// channels of the CURRENT state.
|
|
174
|
+
//
|
|
175
|
+
// ⚠ Only under the bypass. Without it the helper claims no sameness, so
|
|
176
|
+
// `<Link routeName="docs">` means `/docs` — substituting there would
|
|
177
|
+
// turn a real navigation into a no-op. An explicit `routeSearch={{}}`
|
|
178
|
+
// still clears the query, because `{}` is not nullish. Both pinned by
|
|
179
|
+
// the #1925 suite.
|
|
180
|
+
navigatedSearch = sameLocationSearch;
|
|
181
|
+
}
|
|
156
182
|
}
|
|
157
183
|
}
|
|
158
|
-
// Query channel at position 3 (RFC-4 M2 / #1548)
|
|
159
|
-
|
|
160
|
-
return router.navigate(routeName, routeParams, routeSearch, opts);
|
|
184
|
+
// Query channel at position 3 (RFC-4 M2 / #1548); opts at position 4.
|
|
185
|
+
return router.navigate(routeName, routeParams, navigatedSearch, opts);
|
|
161
186
|
}
|
|
162
187
|
// Match-any-whitespace regex shared across calls. RegExp literals at
|
|
163
188
|
// call-site recompile in some engines; lifting it avoids that microcost
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@real-router/svelte",
|
|
3
|
-
"version": "0.17.
|
|
3
|
+
"version": "0.17.33",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "Svelte 5 integration for Real-Router",
|
|
6
6
|
"svelte": "./dist/index.js",
|
|
@@ -48,7 +48,7 @@
|
|
|
48
48
|
"license": "MIT",
|
|
49
49
|
"sideEffects": false,
|
|
50
50
|
"dependencies": {
|
|
51
|
-
"@real-router/core": "^0.111.
|
|
51
|
+
"@real-router/core": "^0.111.5",
|
|
52
52
|
"@real-router/route-utils": "^0.3.0",
|
|
53
53
|
"@real-router/sources": "^0.14.14"
|
|
54
54
|
},
|