Skip to content

Commit

Permalink
Remove sveltekit:start event (#6484)
Browse files Browse the repository at this point in the history
* Remove sveltekit:start event

Closes #6448

* setup

* rename docs files

* Update .changeset/perfect-cycles-smell.md

* comments

Co-authored-by: Gaurav Singh <allstargaurav@gmail.com>
  • Loading branch information
Rich-Harris and illuzan authored Aug 31, 2022
1 parent cade00d commit 70bc001
Show file tree
Hide file tree
Showing 19 changed files with 57 additions and 56 deletions.
5 changes: 5 additions & 0 deletions .changeset/perfect-cycles-smell.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@sveltejs/kit': patch
---

[breaking] Remove sveltekit:start event
File renamed without changes.
7 changes: 0 additions & 7 deletions documentation/docs/10-events.md

This file was deleted.

File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
2 changes: 0 additions & 2 deletions packages/kit/src/runtime/client/start.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,4 @@ export async function start({ env, hydrate, paths, target, trailing_slash }) {
}

client._start_router();

dispatchEvent(new CustomEvent('sveltekit:start'));
}
22 changes: 3 additions & 19 deletions packages/kit/test/apps/basics/src/routes/+layout.svelte
Original file line number Diff line number Diff line change
@@ -1,26 +1,10 @@
<script>
import {
goto,
invalidate,
prefetch,
prefetchRoutes,
beforeNavigate,
afterNavigate
} from '$app/navigation';
if (typeof window !== 'undefined') {
Object.assign(window, {
goto,
invalidate,
prefetch,
prefetchRoutes,
beforeNavigate,
afterNavigate
});
}
import { setup } from '../../../../setup.js';
/** @type {import('./$types').LayoutData} */
export let data;
setup();
</script>

<slot />
Expand Down
7 changes: 7 additions & 0 deletions packages/kit/test/apps/dev-only/src/routes/+layout.svelte
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<script>
import { setup } from '../../../../setup.js';
setup();
</script>

<slot />
7 changes: 7 additions & 0 deletions packages/kit/test/apps/options-2/src/routes/+layout.svelte
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<script>
import { setup } from '../../../../setup.js';
setup();
</script>

<slot />
20 changes: 2 additions & 18 deletions packages/kit/test/apps/options/source/pages/+layout.svelte
Original file line number Diff line number Diff line change
@@ -1,23 +1,7 @@
<script>
import {
goto,
invalidate,
prefetch,
prefetchRoutes,
beforeNavigate,
afterNavigate
} from '$app/navigation';
import { setup } from '../../../../setup.js';
if (typeof window !== 'undefined') {
Object.assign(window, {
goto,
invalidate,
prefetch,
prefetchRoutes,
beforeNavigate,
afterNavigate
});
}
setup();
</script>

<slot />
7 changes: 7 additions & 0 deletions packages/kit/test/apps/writes/src/routes/+layout.svelte
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<script>
import { setup } from '../../../../setup.js';
setup();
</script>

<slot />
26 changes: 26 additions & 0 deletions packages/kit/test/setup.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import {
goto,
invalidate,
prefetch,
prefetchRoutes,
beforeNavigate,
afterNavigate
} from '$app/navigation';
import { onMount } from 'svelte';

export function setup() {
onMount(() => {
// give tests programmatic control over the app
Object.assign(window, {
goto,
invalidate,
prefetch,
prefetchRoutes,
beforeNavigate,
afterNavigate
});

// communicate that the app is ready
document.body.classList.add('started');
});
}
10 changes: 0 additions & 10 deletions packages/kit/test/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -78,16 +78,6 @@ export const test = base.extend({
},

page: async ({ page, javaScriptEnabled }, use) => {
if (javaScriptEnabled) {
page.addInitScript({
content: `
addEventListener('sveltekit:start', () => {
document.body.classList.add('started');
});
`
});
}

// automatically wait for kit started event after navigation functions if js is enabled
const page_navigation_functions = ['goto', 'goBack', 'reload'];
page_navigation_functions.forEach((fn) => {
Expand Down

0 comments on commit 70bc001

Please sign in to comment.