@real-router/svelte 0.17.32 → 0.17.34

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.
@@ -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
- // "Does this link point at where we already are?" is a question the router
131
- // owns, and asking it here by hand got two things wrong at once (#1555).
132
- //
133
- // The hand-rolled version compared with `Object.is` per key, so a link writing
134
- // `routeSearch={{ page: "2" }}` never matched a state parsed from `?page=2`,
135
- // where the value is the NUMBER 2 — the bypass silently did not fire, core
136
- // rejected the navigation as SAME_STATES, and `<Link hash>` looked dead. The
137
- // predicate carries the provenance-tolerant comparison (#1554) that makes the
138
- // two forms equal because they print the same URL.
139
- //
140
- // It also compared the caller's whole `routeParams` bag against `state.params`,
141
- // which stopped meaning anything once the channels split (#1548) — the
142
- // predicate applies the channel rule instead of re-deriving it.
143
- //
144
- // `strictEquality: true` — a link to a PARENT route is a different location, so
145
- // the hierarchical arm must not match. `ignoreQueryParams: false` — the query is
146
- // part of the location here; ignoring it would fire the bypass across a real
147
- // query change and let `force: true` smuggle it through as a hash change.
148
- if (current !== undefined &&
149
- router.isActiveRoute(routeName, routeParams, routeSearch ?? current.search, true, false)) {
150
- const currentHash = current.context?.url?.hash ??
151
- "";
152
- const newHash = hash ?? currentHash;
153
- if (currentHash !== newHash) {
154
- opts.force = true;
155
- opts.hashChange = true;
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) — from the `routeSearch`
159
- // prop; opts at position 4. `undefined` when the link has no `routeSearch`.
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.32",
3
+ "version": "0.17.34",
4
4
  "type": "module",
5
5
  "description": "Svelte 5 integration for Real-Router",
6
6
  "svelte": "./dist/index.js",
@@ -48,9 +48,9 @@
48
48
  "license": "MIT",
49
49
  "sideEffects": false,
50
50
  "dependencies": {
51
- "@real-router/core": "^0.111.0",
51
+ "@real-router/core": "^0.112.0",
52
52
  "@real-router/route-utils": "^0.3.0",
53
- "@real-router/sources": "^0.14.14"
53
+ "@real-router/sources": "^0.14.15"
54
54
  },
55
55
  "devDependencies": {
56
56
  "@sveltejs/package": "2.5.8",
@@ -63,7 +63,7 @@
63
63
  "svelte": "~5.56.4",
64
64
  "svelte-check": "4.6.0",
65
65
  "svelte-eslint-parser": "1.8.0",
66
- "@real-router/browser-plugin": "^0.21.14"
66
+ "@real-router/browser-plugin": "^0.21.15"
67
67
  },
68
68
  "peerDependencies": {
69
69
  "svelte": ">=5.7.0"