From ab3c42465536e3a4a4cb7699de24f6253c6debac Mon Sep 17 00:00:00 2001 From: Pablo Palacios Date: Sun, 15 Nov 2020 22:52:12 +0100 Subject: [PATCH] fluxible-router: remove currentNavigate.route from dehydrated state Besides avoiding unnecessary data to be sent to the client (given that RouteStore currently doesn't need currentNavigate.route to re-hydrate), we prevent browsers to break given that currentNavigate.route.action and currentNavigate.route.handler may contain server transpiled code that is not compatible with them. --- packages/fluxible-router/lib/RouteStore.js | 3 ++- packages/fluxible-router/tests/unit/lib/RouteStore-test.js | 1 + 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/packages/fluxible-router/lib/RouteStore.js b/packages/fluxible-router/lib/RouteStore.js index df091ffd..e2f237b5 100644 --- a/packages/fluxible-router/lib/RouteStore.js +++ b/packages/fluxible-router/lib/RouteStore.js @@ -151,8 +151,9 @@ var RouteStore = createStore({ dehydrate: function () { // no need to dehydrate this._prevNavigate, because it will always // be null on server request + var currentNavigate = Object.assign({}, this._currentNavigate, {route: null}); return { - currentNavigate: this._currentNavigate, + currentNavigate: currentNavigate, routes: this._routes }; }, diff --git a/packages/fluxible-router/tests/unit/lib/RouteStore-test.js b/packages/fluxible-router/tests/unit/lib/RouteStore-test.js index c2507279..6a5e2917 100644 --- a/packages/fluxible-router/tests/unit/lib/RouteStore-test.js +++ b/packages/fluxible-router/tests/unit/lib/RouteStore-test.js @@ -35,6 +35,7 @@ describe('RouteStore', function () { expect(state.currentNavigate.transactionId).to.equal('first'); expect(state.currentNavigate.url).to.equal('/foo'); expect(state.currentNavigate.method).to.equal('get'); + expect(state.currentNavigate.route).to.equal(null); expect(state.routes).to.equal(null); }); });