Comparing version 17.0.3 to 17.1.0
# CHANGELOG | ||
## 17.1.0 | ||
Fixed a lot of behaviors and inApp calculation in router. Now uses history.state to remember deepness of history. | ||
## 17.0.3 | ||
@@ -4,0 +8,0 @@ |
{ | ||
"name": "bobril", | ||
"version": "17.0.3", | ||
"version": "17.1.0", | ||
"description": "Component Oriented MVC Framework with virtual DOM and CSS", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -101,5 +101,9 @@ import { | ||
let myAppStartHistory = history.length; | ||
let historyDeepness = 0; | ||
let programPath = ""; | ||
function history() { | ||
return window.history; | ||
} | ||
function push(path: string, inApp: boolean): void { | ||
@@ -109,3 +113,5 @@ var l = window.location; | ||
programPath = path; | ||
l.hash = path.substring(1); | ||
historyDeepness++; | ||
history().pushState({ historyDeepness }, "", path); | ||
invalidate(); | ||
} else { | ||
@@ -120,3 +126,4 @@ l.href = path; | ||
programPath = path; | ||
l.replace(l.pathname + l.search + path); | ||
history().replaceState({ historyDeepness }, "", path); | ||
invalidate(); | ||
} else { | ||
@@ -128,5 +135,4 @@ l.replace(path); | ||
function pop(distance: number) { | ||
window.history.length; | ||
waitingForPopHashChange = setTimeout(emitOnHashChange, 50) as unknown as number; | ||
window.history.go(-distance); | ||
history().go(-distance); | ||
} | ||
@@ -324,5 +330,17 @@ | ||
addEvent("popstate", 5, (ev: PopStateEvent) => { | ||
let newHistoryDeepness = ev.state?.historyDeepness; | ||
if (newHistoryDeepness != undefined) { | ||
if (newHistoryDeepness != historyDeepness) invalidate(); | ||
historyDeepness = newHistoryDeepness; | ||
} | ||
return false; | ||
}); | ||
var firstRouting = true; | ||
function rootNodeFactory(): IBobrilNode | undefined { | ||
if (waitingForPopHashChange >= 0) return undefined; | ||
if (history().state == undefined && historyDeepness != undefined) { | ||
history().replaceState({ historyDeepness: historyDeepness }, ""); | ||
} | ||
let browserPath = window.location.hash; | ||
@@ -345,3 +363,4 @@ let path = browserPath.substr(1); | ||
if (!currentTransition && matches.length > 0 && browserPath != programPath) { | ||
runTransition(createRedirectPush(matches[0]!.name!, out.p)); | ||
programPath = browserPath; | ||
runTransition(createRedirectReplace(matches[0]!.name!, out.p)); | ||
} | ||
@@ -572,3 +591,3 @@ } | ||
return { | ||
inApp: history.length - distance >= myAppStartHistory, | ||
inApp: historyDeepness - distance >= 0, | ||
type: RouteTransitionType.Pop, | ||
@@ -597,3 +616,2 @@ name: undefined, | ||
} | ||
invalidate(); | ||
} | ||
@@ -633,3 +651,3 @@ | ||
.catch((err: any) => { | ||
if (typeof console !== "undefined" && console.log) console.log(err); | ||
console.log(err); | ||
}); | ||
@@ -674,4 +692,2 @@ return; | ||
doAction(tr!); | ||
} else { | ||
invalidate(); | ||
} | ||
@@ -714,3 +730,3 @@ currentTransition = null; | ||
.catch((err: any) => { | ||
if (typeof console !== "undefined" && console.log) console.log(err); | ||
console.log(err); | ||
}); | ||
@@ -717,0 +733,0 @@ return; |
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
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
385868
21
9249
0