Comparing version 0.9.5 to 0.9.6
@@ -23,3 +23,3 @@ import { Component } from './component'; | ||
/** Sets the current path, setting the history accordingly */ | ||
navigate(childPath: string, action?: Action): Promise<boolean>; | ||
navigate(childPath: string, action?: Action, updateHistory?: boolean): Promise<boolean>; | ||
clearCurrent(recurse?: boolean): void; | ||
@@ -26,0 +26,0 @@ private setChildPath(childPath, action?); |
@@ -60,11 +60,11 @@ "use strict"; | ||
/** Sets the current path, setting the history accordingly */ | ||
Router.prototype.navigate = function (childPath, action) { | ||
Router.prototype.navigate = function (childPath, action, updateHistory) { | ||
if (updateHistory === void 0) { updateHistory = true; } | ||
return __awaiter(this, void 0, void 0, function () { | ||
var query, success; | ||
var success; | ||
return __generator(this, function (_a) { | ||
switch (_a.label) { | ||
case 0: | ||
if (combinePaths("/", childPath) == combinePaths("/", this.pathFull()) + this.query) | ||
if (combinePaths("/", childPath) == this.pathFull()) | ||
return [2 /*return*/, true]; | ||
query = childPath.indexOf("?") == -1 ? "" : childPath.substring(childPath.indexOf("?")); | ||
return [4 /*yield*/, this.root.setChildPath(combinePaths(this.pathRootToThis(false, true), childPath), action)]; | ||
@@ -75,4 +75,5 @@ case 1: | ||
if (success) { | ||
this.query = query; | ||
this.setHistory(action); | ||
this.leaf.query = childPath.indexOf("?") == -1 ? "" : childPath.substring(childPath.indexOf("?")); | ||
if (updateHistory) | ||
this.setHistory(action); | ||
} | ||
@@ -86,8 +87,5 @@ return [2 /*return*/, success]; | ||
if (recurse === void 0) { recurse = false; } | ||
var curChild = this.currentChildComponent; | ||
if (curChild) { | ||
if (recurse) | ||
curChild.router.clearCurrent(); | ||
this.currentChildName = ''; | ||
} | ||
if (recurse && this.currentChildComponent) | ||
this.currentChildComponent.router.clearCurrent(); | ||
this.currentChildName = ''; | ||
}; | ||
@@ -146,3 +144,3 @@ Router.prototype.setChildPath = function (childPath, action) { | ||
Router.prototype.pathFull = function () { | ||
return branch(this.root, this.leaf, true, true); | ||
return combinePaths("/", branch(this.root, this.leaf, true, true)) + this.leaf.query; | ||
}; | ||
@@ -203,3 +201,3 @@ /** Returns the path from the root to this */ | ||
Router.prototype.setHistory = function (action) { | ||
var pathAndQuery = combinePaths("/" + this.pathFull()) + this.query; | ||
var pathAndQuery = this.pathFull(); | ||
if (location.pathname + location.search != pathAndQuery) { | ||
@@ -222,3 +220,3 @@ if (action == 'REPLACE' || util_1.equalsIgnoreCase(location.pathname + location.search, pathAndQuery)) | ||
if (location.pathname.indexOf(rootPath) == 0) | ||
this.navigate(location.pathname.substr(rootPath.length), action); | ||
this.navigate(location.pathname.substr(rootPath.length) + location.search, action, false); | ||
return [2 /*return*/]; | ||
@@ -258,2 +256,4 @@ }); | ||
function splitPath(path) { | ||
if (path && path.indexOf("?") != -1) | ||
path = path.substring(0, path.indexOf("?")); | ||
return path.split('/').filter(function (s) { return s != ''; }); | ||
@@ -260,0 +260,0 @@ } |
{ | ||
"name": "pickle-ts", | ||
"version": "0.9.5", | ||
"version": "0.9.6", | ||
"author": "pickle", | ||
@@ -5,0 +5,0 @@ "license": "MIT", |
@@ -43,16 +43,17 @@ import { Component } from './component' | ||
/** Sets the current path, setting the history accordingly */ | ||
async navigate (childPath: string, action?: Action) : Promise<boolean> | ||
{ | ||
if (combinePaths ("/", childPath) == combinePaths ("/", this.pathFull()) + this.query) | ||
async navigate (childPath: string, action?: Action, updateHistory = true) : Promise<boolean> | ||
{ | ||
if (combinePaths ("/", childPath) == this.pathFull()) | ||
return true | ||
const query = childPath.indexOf ("?") == -1 ? "" : childPath.substring (childPath.indexOf("?")) | ||
const success = await this.root.setChildPath (combinePaths (this.pathRootToThis (false, true), childPath), action) | ||
this.component.update (() => {}) | ||
if (success) { | ||
this.query = query | ||
this.setHistory (action) | ||
this.leaf.query = childPath.indexOf ("?") == -1 ? "" : childPath.substring (childPath.indexOf("?")) | ||
if (updateHistory) | ||
this.setHistory (action) | ||
} | ||
return success | ||
@@ -102,3 +103,3 @@ } | ||
pathFull() { | ||
return branch (this.root, this.leaf, true, true) | ||
return combinePaths ("/", branch (this.root, this.leaf, true, true)) + this.leaf.query | ||
} | ||
@@ -150,3 +151,3 @@ | ||
protected setHistory (action?: Action) { | ||
const pathAndQuery = combinePaths ("/" + this.pathFull()) + this.query | ||
const pathAndQuery = this.pathFull() | ||
if (location.pathname + location.search != pathAndQuery) { | ||
@@ -167,3 +168,3 @@ if (action == 'REPLACE' || equalsIgnoreCase (location.pathname + location.search, pathAndQuery)) | ||
if (location.pathname.indexOf (rootPath) == 0) | ||
this.navigate (location.pathname.substr (rootPath.length), action) | ||
this.navigate (location.pathname.substr (rootPath.length) + location.search, action, false) | ||
}) | ||
@@ -195,3 +196,5 @@ else | ||
export function splitPath (path: string) { | ||
return path.split('/').filter(s => s != '') | ||
if (path && path.indexOf ("?") != -1) | ||
path = path.substring (0, path.indexOf ("?")) | ||
return path.split('/').filter(s => s != '') | ||
} | ||
@@ -198,0 +201,0 @@ |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
238058
4944