From 329c1137235a011f9c3ca03b1a03c796401681b2 Mon Sep 17 00:00:00 2001 From: Rich Harris Date: Sun, 4 Mar 2018 22:38:55 -0500 Subject: [PATCH] rename preloadRoutes to prefetchRoutes --- src/runtime/index.ts | 7 +++++-- test/app/app/client.js | 4 ++-- test/common/test.js | 6 +++--- 3 files changed, 10 insertions(+), 7 deletions(-) diff --git a/src/runtime/index.ts b/src/runtime/index.ts index 445ae67..22cd582 100644 --- a/src/runtime/index.ts +++ b/src/runtime/index.ts @@ -266,7 +266,7 @@ export function goto(href: string, opts = { replaceState: false }) { } } -export function preloadRoutes(pathnames: string[]) { +export function prefetchRoutes(pathnames: string[]) { if (!routes) throw new Error(`You must call init() first`); return routes @@ -281,4 +281,7 @@ export function preloadRoutes(pathnames: string[]) { .reduce((promise: Promise, route) => { return promise.then(route.load); }, Promise.resolve()); -} \ No newline at end of file +} + +// remove this in 0.9 +export { prefetchRoutes as preloadRoutes }; \ No newline at end of file diff --git a/test/app/app/client.js b/test/app/app/client.js index d69dd99..bbe24c6 100644 --- a/test/app/app/client.js +++ b/test/app/app/client.js @@ -1,8 +1,8 @@ -import { init, preloadRoutes } from '../../../runtime.js'; +import { init, prefetchRoutes } from '../../../runtime.js'; import { routes } from './manifest/client.js'; window.init = () => { return init(document.querySelector('#sapper'), routes); }; -window.preloadRoutes = preloadRoutes; \ No newline at end of file +window.prefetchRoutes = prefetchRoutes; \ No newline at end of file diff --git a/test/common/test.js b/test/common/test.js index ee1de09..387bb41 100644 --- a/test/common/test.js +++ b/test/common/test.js @@ -23,8 +23,8 @@ Nightmare.action('init', function(done) { this.evaluate_now(() => window.init(), done); }); -Nightmare.action('preloadRoutes', function(done) { - this.evaluate_now(() => window.preloadRoutes(), done); +Nightmare.action('prefetchRoutes', function(done) { + this.evaluate_now(() => window.prefetchRoutes(), done); }); function run(env) { @@ -159,7 +159,7 @@ function run(env) { }); it('navigates to a new page without reloading', () => { - return capture(() => nightmare.goto(base).init().preloadRoutes()) + return capture(() => nightmare.goto(base).init().prefetchRoutes()) .then(() => { return capture(() => nightmare.click('a[href="/about"]')); })