diff options
author | Francesco Agosti <francesco.agosti93@gmail.com> | 2018-12-01 08:00:30 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-12-01 08:00:30 +0800 |
commit | 502e9c7be48caafd7725451789f896efdaf17dac (patch) | |
tree | 97d12119a1c92458ddac757f04bad6b76042d56b /packages | |
parent | 94d81bd5621535ca3a02ceb690ec963036b0ec6b (diff) | |
parent | e47dd4a83ed52dd246beddeb93fc5de3378fae24 (diff) | |
download | dexon-0x-contracts-502e9c7be48caafd7725451789f896efdaf17dac.tar dexon-0x-contracts-502e9c7be48caafd7725451789f896efdaf17dac.tar.gz dexon-0x-contracts-502e9c7be48caafd7725451789f896efdaf17dac.tar.bz2 dexon-0x-contracts-502e9c7be48caafd7725451789f896efdaf17dac.tar.lz dexon-0x-contracts-502e9c7be48caafd7725451789f896efdaf17dac.tar.xz dexon-0x-contracts-502e9c7be48caafd7725451789f896efdaf17dac.tar.zst dexon-0x-contracts-502e9c7be48caafd7725451789f896efdaf17dac.zip |
Merge pull request #1362 from 0xProject/fix/instant/push-to-history-broken-when-no-onpopstate
[instant] Fix push to history issue on second full render of instant
Diffstat (limited to 'packages')
-rw-r--r-- | packages/instant/src/index.umd.ts | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/packages/instant/src/index.umd.ts b/packages/instant/src/index.umd.ts index 449453b56..7391e2844 100644 --- a/packages/instant/src/index.umd.ts +++ b/packages/instant/src/index.umd.ts @@ -91,12 +91,12 @@ export const render = (config: ZeroExInstantConfig, selector: string = DEFAULT_Z // If the integrator defined a popstate handler, save it to __zeroExInstantIntegratorsPopStateHandler // unless we have already done so on a previous render. const anyWindow = window as any; - if (window.onpopstate && !anyWindow.__zeroExInstantIntegratorsPopStateHandler) { - anyWindow.__zeroExInstantIntegratorsPopStateHandler = window.onpopstate.bind(window); - } - const integratorsOnPopStateHandler = anyWindow.__zeroExInstantIntegratorsPopStateHandler || util.boundNoop; + const popStateExistsAndNotSetPreviously = window.onpopstate && !anyWindow.__zeroExInstantIntegratorsPopStateHandler; + anyWindow.__zeroExInstantIntegratorsPopStateHandler = popStateExistsAndNotSetPreviously + ? anyWindow.onpopstate.bind(window) + : util.boundNoop; const onPopStateHandler = (e: PopStateEvent) => { - integratorsOnPopStateHandler(e); + anyWindow.__zeroExInstantIntegratorsPopStateHandler(e); const newState = e.state; if (newState && newState.zeroExInstantShowing) { // We have returned to a history state that expects instant to be rendered. |