@sveltejs/kit 1.1.2 → 1.1.3
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/package.json
CHANGED
|
@@ -1389,10 +1389,17 @@ export function create_client({ target, base }) {
|
|
|
1389
1389
|
const a = find_anchor(/** @type {Element} */ (event.composedPath()[0]), container);
|
|
1390
1390
|
if (!a) return;
|
|
1391
1391
|
|
|
1392
|
-
const { url, external,
|
|
1393
|
-
const options = get_router_options(a);
|
|
1392
|
+
const { url, external, target } = get_link_info(a, base);
|
|
1394
1393
|
if (!url) return;
|
|
1395
1394
|
|
|
1395
|
+
// bail out before `beforeNavigate` if link opens in a different tab
|
|
1396
|
+
if (target === '_parent' || target === '_top') {
|
|
1397
|
+
if (window.parent !== window) return;
|
|
1398
|
+
} else if (target && target !== '_self') {
|
|
1399
|
+
return;
|
|
1400
|
+
}
|
|
1401
|
+
|
|
1402
|
+
const options = get_router_options(a);
|
|
1396
1403
|
const is_svg_a_element = a instanceof SVGAElement;
|
|
1397
1404
|
|
|
1398
1405
|
// Ignore URL protocols that differ to the current one and are not http(s) (e.g. `mailto:`, `tel:`, `myapp:`, etc.)
|
|
@@ -1410,8 +1417,6 @@ export function create_client({ target, base }) {
|
|
|
1410
1417
|
)
|
|
1411
1418
|
return;
|
|
1412
1419
|
|
|
1413
|
-
if (has.download) return;
|
|
1414
|
-
|
|
1415
1420
|
// Ignore the following but fire beforeNavigate
|
|
1416
1421
|
if (external || options.reload) {
|
|
1417
1422
|
const navigation = before_navigate({ url, type: 'link' });
|
|
@@ -124,16 +124,16 @@ export function get_link_info(a, base) {
|
|
|
124
124
|
url = new URL(a instanceof SVGAElement ? a.href.baseVal : a.href, document.baseURI);
|
|
125
125
|
} catch {}
|
|
126
126
|
|
|
127
|
-
const
|
|
128
|
-
rel_external: (a.getAttribute('rel') || '').split(/\s+/).includes('external'),
|
|
129
|
-
download: a.hasAttribute('download'),
|
|
130
|
-
target: !!(a instanceof SVGAElement ? a.target.baseVal : a.target)
|
|
131
|
-
};
|
|
127
|
+
const target = a instanceof SVGAElement ? a.target.baseVal : a.target;
|
|
132
128
|
|
|
133
129
|
const external =
|
|
134
|
-
!url ||
|
|
130
|
+
!url ||
|
|
131
|
+
!!target ||
|
|
132
|
+
is_external_url(url, base) ||
|
|
133
|
+
(a.getAttribute('rel') || '').split(/\s+/).includes('external') ||
|
|
134
|
+
a.hasAttribute('download');
|
|
135
135
|
|
|
136
|
-
return { url,
|
|
136
|
+
return { url, external, target };
|
|
137
137
|
}
|
|
138
138
|
|
|
139
139
|
/**
|
package/types/ambient.d.ts
CHANGED
|
@@ -11,9 +11,12 @@
|
|
|
11
11
|
* }
|
|
12
12
|
* }
|
|
13
13
|
*
|
|
14
|
-
* export
|
|
14
|
+
* export {};
|
|
15
15
|
* ```
|
|
16
16
|
*
|
|
17
|
+
* The `export {}` line exists because without it, the file would be treated as an _ambient module_ which prevents you from adding `import` declarations.
|
|
18
|
+
* If you need to add ambient `declare module` declarations, do so in a separate file like `src/ambient.d.ts`.
|
|
19
|
+
*
|
|
17
20
|
* By populating these interfaces, you will gain type safety when using `event.locals`, `event.platform`, and `data` from `load` functions.
|
|
18
21
|
*/
|
|
19
22
|
declare namespace App {
|
|
@@ -243,7 +246,8 @@ declare module '$app/navigation' {
|
|
|
243
246
|
|
|
244
247
|
/**
|
|
245
248
|
* A navigation interceptor that triggers before we navigate to a new URL, whether by clicking a link, calling `goto(...)`, or using the browser back/forward controls.
|
|
246
|
-
* Calling `cancel()` will prevent the navigation from completing.
|
|
249
|
+
* Calling `cancel()` will prevent the navigation from completing. If the navigation would have directly unloaded the current page, calling `cancel` will trigger the native
|
|
250
|
+
* browser unload confirmation dialog. In these cases, `navigation.willUnload` is `true`.
|
|
247
251
|
*
|
|
248
252
|
* When a navigation isn't client side, `navigation.to.route.id` will be `null`.
|
|
249
253
|
*
|