Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove sveltekit:start event #6484

Merged
merged 6 commits into from
Aug 31, 2022
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
---

Remove sveltekit:start event
Rich-Harris marked this conversation as resolved.
Show resolved Hide resolved
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.
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 />
24 changes: 24 additions & 0 deletions packages/kit/test/setup.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import {
goto,
invalidate,
prefetch,
prefetchRoutes,
beforeNavigate,
afterNavigate
} from '$app/navigation';
import { onMount } from 'svelte';

export function setup() {
onMount(() => {
Object.assign(window, {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this could use a comment

goto,
invalidate,
prefetch,
prefetchRoutes,
beforeNavigate,
afterNavigate
});

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