bugfix crossdomain back-button

This commit is contained in:
Leon van Kammen 2024-10-14 11:53:17 +02:00
parent 28770956b4
commit b7f3c91b7f
1 changed files with 19 additions and 14 deletions

View File

@ -14,8 +14,11 @@ xrf.navigator = {
xrf.navigator.to = (url,flags,loader,data) => {
if( !url ) throw 'xrf.navigator.to(..) no url given'
let hashbus = xrf.hashbus
let URI
let URI = xrfragment.URI.toAbsolute( xrf.navigator.URI, url )
if( typeof url == 'string' ){
URI = xrfragment.URI.toAbsolute( xrf.navigator.URI, url )
URI.hash = xrf.navigator.reactifyHash(URI.hash) // automatically reflect hash-changes to navigator.to(...)
// decorate with extra state
URI.fileChange = URI.file && URI.URN + URI.file != xrf.navigator.URI.URN + xrf.navigator.URI.file
@ -25,10 +28,12 @@ xrf.navigator.to = (url,flags,loader,data) => {
URI.hasPos = URI.hash.pos ? true : false
URI.duplicatePos = URI.source == xrf.navigator.URI.source && URI.hasPos
URI.hashChange = String(xrf.navigator.URI.fragment||"") != String(URI.fragment||"")
let hashbus = xrf.hashbus
//console.dir({URI1:xrf.navigator.URI,URI2:URI})
}else{
URI = url
url = URI.source
}
URI.last = xrf.navigator.URI
xrf.navigator.URI = URI
let {directory,file,fragment,fileExt} = URI;
@ -105,7 +110,7 @@ xrf.navigator.init = () => {
window.addEventListener('popstate', function (event){
if( xrf.navigator.updateHash.active ){ // ignore programmatic hash updates (causes infinite recursion)
xrf.navigator.to( document.location.href.replace(/.*\?/,'') )
xrf.navigator.to( xrf.navigator.URI.last )
}
})