From c647e9c3a3eb544eb019666d8368742f412e303e Mon Sep 17 00:00:00 2001 From: Michael Jackson Date: Thu, 7 Nov 2019 16:35:18 -0800 Subject: [PATCH] Rename to avoid collision with browser globals --- modules/index.js | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/modules/index.js b/modules/index.js index 00cd424f4..60a833ec9 100644 --- a/modules/index.js +++ b/modules/index.js @@ -2,9 +2,9 @@ const PopAction = 'POP'; const PushAction = 'PUSH'; const ReplaceAction = 'REPLACE'; -const BeforeUnloadEvent = 'beforeunload'; -const PopStateEvent = 'popstate'; -const HashChangeEvent = 'hashchange'; +const BeforeUnloadEventType = 'beforeunload'; +const PopStateEventType = 'popstate'; +const HashChangeEventType = 'hashchange'; // There's some duplication in this code, but only one create* method // should ever be used in a given web page, so it's best for minifying @@ -224,7 +224,7 @@ export const createBrowserHistory = ({ } }; - window.addEventListener(PopStateEvent, handlePop); + window.addEventListener(PopStateEventType, handlePop); let action = PopAction; let [index, location] = getIndexAndLocation(); @@ -319,7 +319,7 @@ export const createBrowserHistory = ({ let unblock = blockers.push(fn); if (blockers.length === 1) { - window.addEventListener(BeforeUnloadEvent, promptBeforeUnload); + window.addEventListener(BeforeUnloadEventType, promptBeforeUnload); } return () => { @@ -329,7 +329,7 @@ export const createBrowserHistory = ({ // still be salvageable in the pagehide event. // See https://html.spec.whatwg.org/#unloading-documents if (!blockers.length) { - window.removeEventListener(BeforeUnloadEvent, promptBeforeUnload); + window.removeEventListener(BeforeUnloadEventType, promptBeforeUnload); } }; }; @@ -426,11 +426,11 @@ export const createHashHistory = ({ window = document.defaultView } = {}) => { } }; - window.addEventListener(PopStateEvent, handlePop); + window.addEventListener(PopStateEventType, handlePop); // TODO: Is this still necessary? Which browsers do // not trigger popstate when the hash changes? - window.addEventListener(HashChangeEvent, event => { + window.addEventListener(HashChangeEventType, event => { let [, nextLocation] = getIndexAndLocation(); // Ignore extraneous hashchange events. @@ -561,7 +561,7 @@ export const createHashHistory = ({ window = document.defaultView } = {}) => { let unblock = blockers.push(fn); if (blockers.length === 1) { - window.addEventListener(BeforeUnloadEvent, promptBeforeUnload); + window.addEventListener(BeforeUnloadEventType, promptBeforeUnload); } return () => { @@ -571,7 +571,7 @@ export const createHashHistory = ({ window = document.defaultView } = {}) => { // still be salvageable in the pagehide event. // See https://html.spec.whatwg.org/#unloading-documents if (!blockers.length) { - window.removeEventListener(BeforeUnloadEvent, promptBeforeUnload); + window.removeEventListener(BeforeUnloadEventType, promptBeforeUnload); } }; };