@sveltejs/kit 1.0.0-next.455 → 1.0.0-next.456
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
|
@@ -71,8 +71,7 @@ export async function write_types(config, manifest_data, file) {
|
|
|
71
71
|
return;
|
|
72
72
|
}
|
|
73
73
|
|
|
74
|
-
const
|
|
75
|
-
const id = path.dirname(filepath);
|
|
74
|
+
const id = path.relative(config.kit.files.routes, path.dirname(file));
|
|
76
75
|
|
|
77
76
|
const route = manifest_data.routes.find((route) => route.id === id);
|
|
78
77
|
if (!route) return; // this shouldn't ever happen
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { onMount, tick } from 'svelte';
|
|
2
2
|
import { normalize_error } from '../../utils/error.js';
|
|
3
3
|
import { make_trackable, decode_params, normalize_path } from '../../utils/url.js';
|
|
4
|
-
import { find_anchor, get_base_uri,
|
|
4
|
+
import { find_anchor, get_base_uri, scroll_state } from './utils.js';
|
|
5
5
|
import { lock_fetch, unlock_fetch, initial_fetch, native_fetch } from './fetcher.js';
|
|
6
6
|
import { parse } from './parse.js';
|
|
7
7
|
import { error } from '../../exports/index.js';
|
|
@@ -1139,9 +1139,9 @@ export function create_client({ target, base, trailing_slash }) {
|
|
|
1139
1139
|
|
|
1140
1140
|
/** @param {Event} event */
|
|
1141
1141
|
const trigger_prefetch = (event) => {
|
|
1142
|
-
const
|
|
1143
|
-
if (
|
|
1144
|
-
prefetch(
|
|
1142
|
+
const { url, options } = find_anchor(event);
|
|
1143
|
+
if (url && options.prefetch === '') {
|
|
1144
|
+
prefetch(url);
|
|
1145
1145
|
}
|
|
1146
1146
|
};
|
|
1147
1147
|
|
|
@@ -1172,13 +1172,10 @@ export function create_client({ target, base, trailing_slash }) {
|
|
|
1172
1172
|
if (event.metaKey || event.ctrlKey || event.shiftKey || event.altKey) return;
|
|
1173
1173
|
if (event.defaultPrevented) return;
|
|
1174
1174
|
|
|
1175
|
-
const a = find_anchor(event);
|
|
1176
|
-
if (!a) return;
|
|
1177
|
-
|
|
1178
|
-
if (!a.href) return;
|
|
1175
|
+
const { a, url, options } = find_anchor(event);
|
|
1176
|
+
if (!a || !url) return;
|
|
1179
1177
|
|
|
1180
1178
|
const is_svg_a_element = a instanceof SVGAElement;
|
|
1181
|
-
const url = get_href(a);
|
|
1182
1179
|
|
|
1183
1180
|
// Ignore non-HTTP URL protocols (e.g. `mailto:`, `tel:`, `myapp:`, etc.)
|
|
1184
1181
|
// MEMO: Without this condition, firefox will open mailer twice.
|
|
@@ -1192,11 +1189,7 @@ export function create_client({ target, base, trailing_slash }) {
|
|
|
1192
1189
|
// 2. 'rel' attribute includes external
|
|
1193
1190
|
const rel = (a.getAttribute('rel') || '').split(/\s+/);
|
|
1194
1191
|
|
|
1195
|
-
if (
|
|
1196
|
-
a.hasAttribute('download') ||
|
|
1197
|
-
rel.includes('external') ||
|
|
1198
|
-
a.hasAttribute('data-sveltekit-reload')
|
|
1199
|
-
) {
|
|
1192
|
+
if (a.hasAttribute('download') || rel.includes('external') || options.reload === '') {
|
|
1200
1193
|
return;
|
|
1201
1194
|
}
|
|
1202
1195
|
|
|
@@ -1222,7 +1215,7 @@ export function create_client({ target, base, trailing_slash }) {
|
|
|
1222
1215
|
|
|
1223
1216
|
navigate({
|
|
1224
1217
|
url,
|
|
1225
|
-
scroll:
|
|
1218
|
+
scroll: options.noscroll === '' ? scroll_state() : null,
|
|
1226
1219
|
keepfocus: false,
|
|
1227
1220
|
redirect_chain: [],
|
|
1228
1221
|
details: {
|
|
@@ -24,17 +24,44 @@ export function scroll_state() {
|
|
|
24
24
|
|
|
25
25
|
/** @param {Event} event */
|
|
26
26
|
export function find_anchor(event) {
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
}
|
|
27
|
+
/** @type {HTMLAnchorElement | SVGAElement | undefined} */
|
|
28
|
+
let a;
|
|
29
|
+
|
|
30
|
+
const options = {
|
|
31
|
+
/** @type {string | null} */
|
|
32
|
+
noscroll: null,
|
|
33
|
+
|
|
34
|
+
/** @type {string | null} */
|
|
35
|
+
prefetch: null,
|
|
36
|
+
|
|
37
|
+
/** @type {string | null} */
|
|
38
|
+
reload: null
|
|
39
|
+
};
|
|
40
|
+
|
|
41
|
+
for (const element of event.composedPath()) {
|
|
42
|
+
if (!(element instanceof Element)) continue;
|
|
43
|
+
|
|
44
|
+
if (!a && element.nodeName.toUpperCase() === 'A') {
|
|
45
|
+
// SVG <a> elements have a lowercase name
|
|
46
|
+
a = /** @type {HTMLAnchorElement | SVGAElement} */ (element);
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
if (options.noscroll === null) {
|
|
50
|
+
options.noscroll = element.getAttribute('data-sveltekit-noscroll');
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
if (options.prefetch === null) {
|
|
54
|
+
options.prefetch = element.getAttribute('data-sveltekit-prefetch');
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
if (options.reload === null) {
|
|
58
|
+
options.reload = element.getAttribute('data-sveltekit-reload');
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
const url = a && new URL(a instanceof SVGAElement ? a.href.baseVal : a.href, document.baseURI);
|
|
32
63
|
|
|
33
|
-
|
|
34
|
-
export function get_href(node) {
|
|
35
|
-
return node instanceof SVGAElement
|
|
36
|
-
? new URL(node.href.baseVal, document.baseURI)
|
|
37
|
-
: new URL(node.href);
|
|
64
|
+
return { a, url, options };
|
|
38
65
|
}
|
|
39
66
|
|
|
40
67
|
/** @param {any} value */
|