Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor!: Remove dom-helpers #215

Merged
merged 3 commits into from
Mar 11, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@
},
"homepage": "https://github.com/4Catalyzer/farce#readme",
"dependencies": {
"dom-helpers": "^3.4.0",
"invariant": "^2.2.4",
"is-promise": "^2.1.0",
"query-string": "^5.1.1",
Expand Down
6 changes: 2 additions & 4 deletions src/BrowserProtocol.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import off from 'dom-helpers/events/off';
import on from 'dom-helpers/events/on';
import invariant from 'invariant';

import createPath from './utils/createPath';
Expand Down Expand Up @@ -41,8 +39,8 @@ export default class BrowserProtocol {
// TODO: On most versions of IE, we need a hashChange listener for hash-
// only changes.

on(window, 'popstate', onPopState);
return () => off(window, 'popstate', onPopState);
window.addEventListener('popstate', onPopState);
return () => window.removeEventListener('popstate', onPopState);
}

transition(location) {
Expand Down
6 changes: 2 additions & 4 deletions src/HashProtocol.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import off from 'dom-helpers/events/off';
import on from 'dom-helpers/events/on';
import invariant from 'invariant';

import StateStorage from './StateStorage';
Expand Down Expand Up @@ -42,8 +40,8 @@ export default class HashProtocol {
listener(this.init());
};

on(window, 'hashchange', onHashChange);
return () => off(window, 'hashchange', onHashChange);
window.addEventListener('hashchange', onHashChange);
return () => window.removeEventListener('hashchange', onHashChange);
}

transition(location) {
Expand Down
6 changes: 2 additions & 4 deletions src/createTransitionHookMiddleware.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import off from 'dom-helpers/events/off';
import on from 'dom-helpers/events/on';
import isPromise from 'is-promise';
import warning from 'warning';

Expand Down Expand Up @@ -115,7 +113,7 @@ export default function createTransitionHookMiddleware({
return resultSafe;
};

on(window, 'beforeunload', onBeforeUnload);
window.addEventListener('beforeunload', onBeforeUnload);
}

return next(action);
Expand Down Expand Up @@ -207,7 +205,7 @@ export default function createTransitionHookMiddleware({
}
case ActionTypes.DISPOSE:
if (onBeforeUnload) {
off(window, 'beforeunload', onBeforeUnload);
window.removeEventListener('beforeunload', onBeforeUnload);
onBeforeUnload = null;
}

Expand Down
9 changes: 1 addition & 8 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -847,7 +847,7 @@
"@babel/plugin-transform-react-jsx-self" "^7.8.3"
"@babel/plugin-transform-react-jsx-source" "^7.8.3"

"@babel/runtime@^7.1.2", "@babel/runtime@^7.6.3":
"@babel/runtime@^7.6.3":
version "7.7.7"
resolved "https://registry.yarnpkg.com/@babel/runtime/-/runtime-7.7.7.tgz#194769ca8d6d7790ec23605af9ee3e42a0aa79cf"
integrity sha512-uCnC2JEVAu8AKB5do1WRIsvrdJ0flYx/A/9f/6chdacnEZ7LmavjdsDXr5ksYBegxtuTPR5Va9/+13QF/kFkCA==
Expand Down Expand Up @@ -2476,13 +2476,6 @@ doctrine@^3.0.0:
dependencies:
esutils "^2.0.2"

dom-helpers@^3.4.0:
version "3.4.0"
resolved "https://registry.yarnpkg.com/dom-helpers/-/dom-helpers-3.4.0.tgz#e9b369700f959f62ecde5a6babde4bccd9169af8"
integrity sha512-LnuPJ+dwqKDIyotW1VzmOZ5TONUN7CwkCR5hrgawTUbkBGYdeoNLZo6nNfGkCrjtE1nXXaj7iMMpDa8/d9WoIA==
dependencies:
"@babel/runtime" "^7.1.2"

dom-serialize@^2.2.0:
version "2.2.1"
resolved "https://registry.yarnpkg.com/dom-serialize/-/dom-serialize-2.2.1.tgz#562ae8999f44be5ea3076f5419dcd59eb43ac95b"
Expand Down