Files
frontend/src/common/navigate.ts
Paulus Schoutsen d6887758a9 Convert <home-assistant> to Lit/TS (#2586)
* Convert home-assistant element to Lit/TS

* Fix disconnect toast

* Lint
2019-01-27 10:41:35 -08:00

23 lines
480 B
TypeScript

import { fireEvent } from "./dom/fire_event";
export const navigate = (
_node: any,
path: string,
replace: boolean = false
) => {
if (__DEMO__) {
if (replace) {
history.replaceState(null, "", `${location.pathname}#${path}`);
} else {
window.location.hash = path;
}
} else {
if (replace) {
history.replaceState(null, "", path);
} else {
history.pushState(null, "", path);
}
}
fireEvent(window, "location-changed");
};