mirror of
https://github.com/microsoft/playwright.git
synced 2025-06-26 21:40:17 +00:00

Repro: `cd tests/components/ct-svelte && rm -rf node_modules package-lock.json && npm i && npx playwright test --project=chromium` Follow-up based on https://github.com/microsoft/playwright/pull/28624#issuecomment-1858608101. Svelte has no router by default, only SvelteKit - so lets remove the package which is not maintained anymore and not recommended.
35 lines
835 B
Svelte
35 lines
835 B
Svelte
<script>
|
|
import { onMount, onDestroy } from 'svelte';
|
|
import LoginPage from './pages/LoginPage.svelte';
|
|
import DashboardPage from './pages/DashboardPage.svelte';
|
|
|
|
let path = '';
|
|
function updatePath() {
|
|
path = window.location.pathname;
|
|
}
|
|
onMount(() => {
|
|
updatePath();
|
|
window.addEventListener('popstate', updatePath);
|
|
});
|
|
onDestroy(() => {
|
|
window.removeEventListener('popstate', updatePath);
|
|
});
|
|
/**
|
|
* @param newPath {string}
|
|
*/
|
|
function navigate(newPath) {
|
|
history.pushState({}, '', newPath);
|
|
updatePath();
|
|
}
|
|
</script>
|
|
|
|
<header>
|
|
<a on:click={(e) => { e.preventDefault(); navigate('/'); }} href='/login'>Login</a>
|
|
<a on:click={(e) => { e.preventDefault(); navigate('/dashboard'); }} href='/dashboard'>Dashboard</a>
|
|
</header>
|
|
{#if path === '/'}
|
|
<LoginPage />
|
|
{:else if path === '/dashboard'}
|
|
<DashboardPage />
|
|
{/if}
|