Extract navigate mixin (#1865)

* Extract navigate to function

* Remove eventsmixin properly and side effects
This commit is contained in:
Paulus Schoutsen
2018-10-27 10:56:03 +02:00
committed by GitHub
parent 13c5724d7c
commit 35194cf345
4 changed files with 22 additions and 12 deletions

14
src/common/navigate.ts Normal file
View File

@@ -0,0 +1,14 @@
import { fireEvent } from "./dom/fire_event.js";
export const navigate = (
node: HTMLElement,
path: string,
replace: boolean = false
) => {
if (replace) {
history.replaceState(null, "", path);
} else {
history.pushState(null, "", path);
}
fireEvent(node, "location-changed");
};