mirror of
https://github.com/kevin-DL/sapper.git
synced 2026-01-14 20:14:39 +00:00
@@ -22,10 +22,7 @@ export default {
|
||||
emitCss: true
|
||||
}),
|
||||
resolve()
|
||||
],
|
||||
|
||||
// temporary, pending Rollup 1.0
|
||||
experimentalCodeSplitting: true
|
||||
]
|
||||
},
|
||||
|
||||
server: {
|
||||
@@ -44,10 +41,7 @@ export default {
|
||||
preferBuiltins: true
|
||||
})
|
||||
],
|
||||
external: ['sirv', 'polka'],
|
||||
|
||||
// temporary, pending Rollup 1.0
|
||||
experimentalCodeSplitting: true
|
||||
external: ['sirv', 'polka']
|
||||
},
|
||||
|
||||
serviceworker: {
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import * as sapper from '../__sapper__/client.js';
|
||||
import * as sapper from '@sapper/app';
|
||||
|
||||
window.start = () => sapper.start({
|
||||
target: document.querySelector('#sapper')
|
||||
|
||||
@@ -1,2 +1,4 @@
|
||||
<h1>Another tall page</h1>
|
||||
|
||||
<div style="height: 9999px"></div>
|
||||
<p id="bar">element</p>
|
||||
@@ -1,3 +1,15 @@
|
||||
<script>
|
||||
import { onMount } from 'svelte';
|
||||
|
||||
export let barLink = false;
|
||||
|
||||
onMount(() => {
|
||||
barLink = true
|
||||
});
|
||||
</script>
|
||||
|
||||
<h1>A tall page</h1>
|
||||
|
||||
<a href="tall-page#foo">scroll to foo</a>
|
||||
<div style="height: 9999px"></div>
|
||||
|
||||
@@ -7,18 +19,4 @@
|
||||
{#if barLink}
|
||||
<a href="another-tall-page#bar">link</a>
|
||||
{/if}
|
||||
</div>
|
||||
|
||||
<script>
|
||||
export default {
|
||||
data() {
|
||||
return {
|
||||
barLink: false
|
||||
};
|
||||
},
|
||||
|
||||
oncreate() {
|
||||
this.set({ barLink: true })
|
||||
}
|
||||
}
|
||||
</script>
|
||||
</div>
|
||||
@@ -1,5 +1,5 @@
|
||||
import polka from 'polka';
|
||||
import * as sapper from '../__sapper__/server.js';
|
||||
import * as sapper from '@sapper/server';
|
||||
|
||||
const { PORT } = process.env;
|
||||
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
import { timestamp, files, shell, routes } from '../__sapper__/service-worker.js';
|
||||
import * as sapper from '@sapper/service-worker';
|
||||
|
||||
const ASSETS = `cache${timestamp}`;
|
||||
const ASSETS = `cache${sapper.timestamp}`;
|
||||
|
||||
// `shell` is an array of all the files generated by webpack,
|
||||
// `files` is an array of everything in the `static` directory
|
||||
const to_cache = shell.concat(ASSETS);
|
||||
const to_cache = sapper.shell.concat(sapper.files);
|
||||
const cached = new Set(to_cache);
|
||||
|
||||
self.addEventListener('install', event => {
|
||||
@@ -65,7 +65,7 @@ self.addEventListener('fetch', event => {
|
||||
// might prefer a cache-first approach to a network-first one.)
|
||||
event.respondWith(
|
||||
caches
|
||||
.open(`offline${timestamp}`)
|
||||
.open(`offline${sapper.timestamp}`)
|
||||
.then(async cache => {
|
||||
try {
|
||||
const response = await fetch(event.request);
|
||||
|
||||
@@ -14,13 +14,14 @@ describe('scroll', function() {
|
||||
// helpers
|
||||
let start: () => Promise<void>;
|
||||
let prefetchRoutes: () => Promise<void>;
|
||||
let title: () => Promise<string>;
|
||||
|
||||
// hooks
|
||||
before(async () => {
|
||||
await build({ cwd: __dirname });
|
||||
|
||||
runner = new AppRunner(__dirname, '__sapper__/build/server/server.js');
|
||||
({ base, page, start, prefetchRoutes } = await runner.start());
|
||||
({ base, page, start, prefetchRoutes, title } = await runner.start());
|
||||
});
|
||||
|
||||
after(() => runner.end());
|
||||
@@ -30,7 +31,7 @@ describe('scroll', function() {
|
||||
await start();
|
||||
|
||||
const scrollY = await page.evaluate(() => window.scrollY);
|
||||
assert.ok(scrollY > 0, scrollY);
|
||||
assert.ok(scrollY > 0, String(scrollY));
|
||||
});
|
||||
|
||||
it('scrolls to any deeplink if it was already active', async () => {
|
||||
@@ -38,17 +39,17 @@ describe('scroll', function() {
|
||||
await start();
|
||||
|
||||
let scrollY = await page.evaluate(() => window.scrollY);
|
||||
assert.ok(scrollY > 0, scrollY);
|
||||
assert.ok(scrollY > 0, String(scrollY));
|
||||
|
||||
scrollY = await page.evaluate(() => {
|
||||
window.scrollTo(0, 0)
|
||||
return window.scrollY
|
||||
});
|
||||
assert.ok(scrollY === 0, scrollY);
|
||||
assert.ok(scrollY === 0, String(scrollY));
|
||||
|
||||
await page.click('[href="tall-page#foo"]');
|
||||
scrollY = await page.evaluate(() => window.scrollY);
|
||||
assert.ok(scrollY > 0, scrollY);
|
||||
assert.ok(scrollY > 0, String(scrollY));
|
||||
});
|
||||
|
||||
it('resets scroll when a link is clicked', async () => {
|
||||
@@ -85,6 +86,7 @@ describe('scroll', function() {
|
||||
|
||||
await page.click('[href="another-tall-page#bar"]');
|
||||
await wait(50);
|
||||
assert.equal(await title(), 'Another tall page');
|
||||
const scrollY = await page.evaluate(() => window.scrollY);
|
||||
assert.ok(scrollY > 0);
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user