@real-router/svelte 0.16.0 → 0.16.2
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.
|
@@ -72,7 +72,7 @@
|
|
|
72
72
|
router,
|
|
73
73
|
routeName,
|
|
74
74
|
routeParams ?? EMPTY_PARAMS,
|
|
75
|
-
hash
|
|
75
|
+
hash,
|
|
76
76
|
),
|
|
77
77
|
);
|
|
78
78
|
|
|
@@ -82,7 +82,19 @@
|
|
|
82
82
|
|
|
83
83
|
function handleClick(evt: MouseEvent) {
|
|
84
84
|
if (userOnClick) {
|
|
85
|
-
|
|
85
|
+
// Isolate a throwing user handler (#1436): native <a> logs a throwing
|
|
86
|
+
// click listener and still performs the default action. Without this the
|
|
87
|
+
// throw escapes before navigateWithHash, silently aborting navigation.
|
|
88
|
+
// The user's own preventDefault() runs before any throw, so the
|
|
89
|
+
// defaultPrevented contract below is unchanged. Mirrors vue's #1352.
|
|
90
|
+
try {
|
|
91
|
+
userOnClick(evt);
|
|
92
|
+
} catch (error) {
|
|
93
|
+
console.error(
|
|
94
|
+
"[real-router] A <Link> onclick handler threw; navigation is unaffected.",
|
|
95
|
+
error,
|
|
96
|
+
);
|
|
97
|
+
}
|
|
86
98
|
|
|
87
99
|
if (evt.defaultPrevented) {
|
|
88
100
|
return;
|
|
@@ -8,14 +8,12 @@ export declare function shouldNavigate(evt: MouseEvent): boolean;
|
|
|
8
8
|
* - Falls back to `router.buildPath` for runtimes without a URL plugin
|
|
9
9
|
* (memory-plugin, console UIs, NativeScript). In that fallback the hash
|
|
10
10
|
* is appended manually so the rendered href is still correct.
|
|
11
|
-
* - The optional 4th argument is
|
|
12
|
-
*
|
|
13
|
-
*
|
|
14
|
-
*
|
|
11
|
+
* - The optional 4th argument is the decoded hash fragment (no leading "#";
|
|
12
|
+
* `<Link hash="#section">` is accepted defensively — leading "#" stripped),
|
|
13
|
+
* passed positionally to mirror `navigateWithHash(router, name, params, hash)`
|
|
14
|
+
* (#1442). Previous 3-arg call sites continue to work unchanged.
|
|
15
15
|
*/
|
|
16
|
-
export declare function buildHref(router: Router, routeName: string, routeParams: Params,
|
|
17
|
-
hash?: string;
|
|
18
|
-
}): string | undefined;
|
|
16
|
+
export declare function buildHref(router: Router, routeName: string, routeParams: Params, hash?: string): string | undefined;
|
|
19
17
|
export declare function navigateWithHash(router: Router, routeName: string, routeParams: Params, hash: string | undefined, extraOptions?: NavigationOptions): Promise<State>;
|
|
20
18
|
export declare function buildActiveClassName(isActive: boolean, activeClassName: string | undefined, baseClassName: string | undefined): string | undefined;
|
|
21
19
|
/**
|
|
@@ -33,17 +33,16 @@ function encodeFragmentInline(decoded) {
|
|
|
33
33
|
* - Falls back to `router.buildPath` for runtimes without a URL plugin
|
|
34
34
|
* (memory-plugin, console UIs, NativeScript). In that fallback the hash
|
|
35
35
|
* is appended manually so the rendered href is still correct.
|
|
36
|
-
* - The optional 4th argument is
|
|
37
|
-
*
|
|
38
|
-
*
|
|
39
|
-
*
|
|
36
|
+
* - The optional 4th argument is the decoded hash fragment (no leading "#";
|
|
37
|
+
* `<Link hash="#section">` is accepted defensively — leading "#" stripped),
|
|
38
|
+
* passed positionally to mirror `navigateWithHash(router, name, params, hash)`
|
|
39
|
+
* (#1442). Previous 3-arg call sites continue to work unchanged.
|
|
40
40
|
*/
|
|
41
|
-
export function buildHref(router, routeName, routeParams,
|
|
41
|
+
export function buildHref(router, routeName, routeParams, hash) {
|
|
42
42
|
try {
|
|
43
|
-
const rawHash = options?.hash;
|
|
44
43
|
let normHash;
|
|
45
|
-
if (
|
|
46
|
-
normHash =
|
|
44
|
+
if (hash !== undefined) {
|
|
45
|
+
normHash = hash.startsWith("#") ? hash.slice(1) : hash;
|
|
47
46
|
}
|
|
48
47
|
const buildUrl = router.buildUrl;
|
|
49
48
|
if (buildUrl) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@real-router/svelte",
|
|
3
|
-
"version": "0.16.
|
|
3
|
+
"version": "0.16.2",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "Svelte 5 integration for Real-Router",
|
|
6
6
|
"svelte": "./dist/index.js",
|
|
@@ -49,8 +49,8 @@
|
|
|
49
49
|
"sideEffects": false,
|
|
50
50
|
"dependencies": {
|
|
51
51
|
"@real-router/core": "^0.76.0",
|
|
52
|
-
"@real-router/
|
|
53
|
-
"@real-router/
|
|
52
|
+
"@real-router/sources": "^0.11.4",
|
|
53
|
+
"@real-router/route-utils": "^0.2.8"
|
|
54
54
|
},
|
|
55
55
|
"devDependencies": {
|
|
56
56
|
"@sveltejs/package": "2.5.8",
|