From 1b67687b772a97f716a88b1c55dd685f5a5e16f5 Mon Sep 17 00:00:00 2001 From: JC Perez Chavez Date: Mon, 16 Apr 2018 00:12:25 -0400 Subject: [PATCH] Issue 54, basic SSR --- src/location.js | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/location.js b/src/location.js index 1bd704e..b627c0f 100644 --- a/src/location.js +++ b/src/location.js @@ -16,12 +16,16 @@ function wrapHistory(keys) { export var location = { state: { - pathname: window.location.pathname, - previous: window.location.pathname + pathname: typeof window === 'undefined' ? '' : window.location.pathname, + previous: typeof window === 'undefined' ? '' : window.location.pathname }, actions: { go: function(pathname) { - history.pushState(null, "", pathname) + return function(state, actions) { + typeof history === 'undefined' + ? actions.set({ pathname: pathname, previous: state.pathname }) + : history.pushState(null, "", pathname) + } }, set: function(data) { return data