bugfix crossdomain back-button

This commit is contained in:
Leon van Kammen 2024-10-14 11:53:17 +02:00
parent 28770956b4
commit b7f3c91b7f

View file

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