@@ -89,6 +89,7 @@ function check_for_removed_attributes() {
89
89
* @returns {import('./types').Client }
90
90
*/
91
91
export function create_client ( { target, base } ) {
92
+ const container = __SVELTEKIT_EMBEDDED__ ? target : document . documentElement ;
92
93
/** @type {Array<((url: URL) => boolean)> } */
93
94
const invalidated = [ ] ;
94
95
@@ -1199,7 +1200,7 @@ export function create_client({ target, base }) {
1199
1200
/** @type {NodeJS.Timeout } */
1200
1201
let mousemove_timeout ;
1201
1202
1202
- target . addEventListener ( 'mousemove' , ( event ) => {
1203
+ container . addEventListener ( 'mousemove' , ( event ) => {
1203
1204
const target = /** @type {Element } */ ( event . target ) ;
1204
1205
1205
1206
clearTimeout ( mousemove_timeout ) ;
@@ -1213,8 +1214,8 @@ export function create_client({ target, base }) {
1213
1214
preload ( /** @type {Element } */ ( event . composedPath ( ) [ 0 ] ) , 1 ) ;
1214
1215
}
1215
1216
1216
- target . addEventListener ( 'mousedown' , tap ) ;
1217
- target . addEventListener ( 'touchstart' , tap , { passive : true } ) ;
1217
+ container . addEventListener ( 'mousedown' , tap ) ;
1218
+ container . addEventListener ( 'touchstart' , tap , { passive : true } ) ;
1218
1219
1219
1220
const observer = new IntersectionObserver (
1220
1221
( entries ) => {
@@ -1233,7 +1234,7 @@ export function create_client({ target, base }) {
1233
1234
* @param {number } priority
1234
1235
*/
1235
1236
function preload ( element , priority ) {
1236
- const a = find_anchor ( element , target ) ;
1237
+ const a = find_anchor ( element , container ) ;
1237
1238
if ( ! a ) return ;
1238
1239
1239
1240
const { url, external } = get_link_info ( a , base ) ;
@@ -1253,7 +1254,7 @@ export function create_client({ target, base }) {
1253
1254
function after_navigate ( ) {
1254
1255
observer . disconnect ( ) ;
1255
1256
1256
- for ( const a of target . querySelectorAll ( 'a' ) ) {
1257
+ for ( const a of container . querySelectorAll ( 'a' ) ) {
1257
1258
const { url, external } = get_link_info ( a , base ) ;
1258
1259
if ( external ) continue ;
1259
1260
@@ -1457,14 +1458,14 @@ export function create_client({ target, base }) {
1457
1458
}
1458
1459
1459
1460
/** @param {MouseEvent } event */
1460
- target . addEventListener ( 'click' , ( event ) => {
1461
+ container . addEventListener ( 'click' , ( event ) => {
1461
1462
// Adapted from https://github.com/visionmedia/page.js
1462
1463
// MIT license https://github.com/visionmedia/page.js#license
1463
1464
if ( event . button || event . which !== 1 ) return ;
1464
1465
if ( event . metaKey || event . ctrlKey || event . shiftKey || event . altKey ) return ;
1465
1466
if ( event . defaultPrevented ) return ;
1466
1467
1467
- const a = find_anchor ( /** @type {Element } */ ( event . composedPath ( ) [ 0 ] ) , target ) ;
1468
+ const a = find_anchor ( /** @type {Element } */ ( event . composedPath ( ) [ 0 ] ) , container ) ;
1468
1469
if ( ! a ) return ;
1469
1470
1470
1471
const { url, external, has } = get_link_info ( a , base ) ;
@@ -1534,7 +1535,7 @@ export function create_client({ target, base }) {
1534
1535
} ) ;
1535
1536
} ) ;
1536
1537
1537
- target . addEventListener ( 'submit' , ( event ) => {
1538
+ container . addEventListener ( 'submit' , ( event ) => {
1538
1539
if ( event . defaultPrevented ) return ;
1539
1540
1540
1541
const form = /** @type {HTMLFormElement } */ (
@@ -1639,11 +1640,25 @@ export function create_client({ target, base }) {
1639
1640
} ) ;
1640
1641
} ,
1641
1642
1642
- _hydrate : async ( { status, error, node_ids, params, route, data : server_data_nodes , form } ) => {
1643
+ _hydrate : async ( {
1644
+ status = 200 ,
1645
+ error,
1646
+ node_ids,
1647
+ params,
1648
+ route,
1649
+ data : server_data_nodes ,
1650
+ form
1651
+ } ) => {
1643
1652
hydrated = true ;
1644
1653
1645
1654
const url = new URL ( location . href ) ;
1646
1655
1656
+ if ( ! __SVELTEKIT_EMBEDDED__ ) {
1657
+ // See https://github.com/sveltejs/kit/pull/4935#issuecomment-1328093358 for one motivation
1658
+ // of determining the params on the client side.
1659
+ ( { params = { } , route = { id : null } } = get_navigation_intent ( url , false ) || { } ) ;
1660
+ }
1661
+
1647
1662
/** @type {import('./types').NavigationFinished | undefined } */
1648
1663
let result ;
1649
1664
0 commit comments