fix(router): writeURL() for non root base

This commit is contained in:
Manu Mtz.-Almeida
2018-04-30 14:16:38 +02:00
parent e56b2ee1a5
commit af4bcb8dcf
2 changed files with 16 additions and 5 deletions

View File

@@ -58,7 +58,16 @@ export function readNavState(root: HTMLElement | undefined) {
return {ids, outlet};
}
const QUERY = ':not([no-router]) ion-nav,:not([no-router]) ion-tabs, :not([no-router]) ion-router-outlet';
export function waitUntilNavNode(win: Window) {
if (searchNavNode(win.document.body)) {
return Promise.resolve();
}
return new Promise((resolve) => {
win.addEventListener('ionNavWillLoad', resolve, { once: true });
});
}
const QUERY = ':not([no-router]) ion-nav, :not([no-router]) ion-tabs, :not([no-router]) ion-router-outlet';
function searchNavNode(root: HTMLElement|undefined): NavOutletElement|null {
if (!root) {

View File

@@ -26,10 +26,12 @@ export function chainToPath(chain: RouteChain): string[]|null {
return path;
}
export function writePath(history: History, base: string, usePath: boolean, path: string[], direction: RouterDirection, state: number) {
path = [base, ...path];
let url = generatePath(path);
if (usePath) {
export function writePath(history: History, root: string, useHash: boolean, path: string[], direction: RouterDirection, state: number) {
let url = generatePath([
...parsePath(root),
...path
]);
if (useHash) {
url = '#' + url;
}
if (direction === RouterDirection.Forward) {