@@ -275,6 +275,11 @@ var htmx = (function() {
275275 } ,
276276 /** @type {typeof parseInterval } */
277277 parseInterval : null ,
278+ /**
279+ * proxy of window.location used for page reload functions
280+ * @type location
281+ */
282+ location,
278283 /** @type {typeof internalEval } */
279284 _ : null ,
280285 version : '2.0.4'
@@ -2359,7 +2364,7 @@ var htmx = (function() {
23592364 if ( path == null || path === '' ) {
23602365 // if there is no action attribute on the form set path to current href before the
23612366 // following logic to properly clear parameters on a GET (not on a POST!)
2362- path = getDocument ( ) . location . href
2367+ path = location . href
23632368 }
23642369 if ( verb === 'get' && path . includes ( '?' ) ) {
23652370 path = path . replace ( / \? [ ^ # ] + / , '' )
@@ -3186,7 +3191,7 @@ var htmx = (function() {
31863191 saveToHistoryCache ( path , elt )
31873192 }
31883193
3189- if ( htmx . config . historyEnabled ) history . replaceState ( { htmx : true } , getDocument ( ) . title , window . location . href )
3194+ if ( htmx . config . historyEnabled ) history . replaceState ( { htmx : true } , getDocument ( ) . title , location . href )
31903195 }
31913196
31923197 /**
@@ -3233,7 +3238,7 @@ var htmx = (function() {
32333238 request . open ( 'GET' , path , true )
32343239 request . setRequestHeader ( 'HX-Request' , 'true' )
32353240 request . setRequestHeader ( 'HX-History-Restore-Request' , 'true' )
3236- request . setRequestHeader ( 'HX-Current-URL' , getDocument ( ) . location . href )
3241+ request . setRequestHeader ( 'HX-Current-URL' , location . href )
32373242 request . onload = function ( ) {
32383243 if ( this . status >= 200 && this . status < 400 ) {
32393244 triggerEvent ( getDocument ( ) . body , 'htmx:historyCacheMissLoad' , details )
@@ -3282,7 +3287,7 @@ var htmx = (function() {
32823287 if ( htmx . config . refreshOnHistoryMiss ) {
32833288 // @ts -ignore: optional parameter in reload() function throws error
32843289 // noinspection JSUnresolvedReference
3285- window . location . reload ( true )
3290+ htmx . location . reload ( true )
32863291 } else {
32873292 loadHistoryFromServer ( path )
32883293 }
@@ -3614,7 +3619,7 @@ var htmx = (function() {
36143619 'HX-Trigger' : getRawAttribute ( elt , 'id' ) ,
36153620 'HX-Trigger-Name' : getRawAttribute ( elt , 'name' ) ,
36163621 'HX-Target' : getAttributeValue ( target , 'id' ) ,
3617- 'HX-Current-URL' : getDocument ( ) . location . href
3622+ 'HX-Current-URL' : location . href
36183623 }
36193624 getValuesForElement ( elt , 'hx-headers' , false , headers )
36203625 if ( prompt !== undefined ) {
@@ -4359,7 +4364,7 @@ var htmx = (function() {
43594364
43604365 // behavior of anchors w/ empty href is to use the current URL
43614366 if ( path == null || path === '' ) {
4362- path = getDocument ( ) . location . href
4367+ path = location . href
43634368 }
43644369
43654370 /**
@@ -4723,14 +4728,14 @@ var htmx = (function() {
47234728
47244729 if ( hasHeader ( xhr , / H X - R e d i r e c t : / i) ) {
47254730 responseInfo . keepIndicators = true
4726- location . href = xhr . getResponseHeader ( 'HX-Redirect' )
4727- shouldRefresh && location . reload ( )
4731+ htmx . location . href = xhr . getResponseHeader ( 'HX-Redirect' )
4732+ shouldRefresh && htmx . location . reload ( )
47284733 return
47294734 }
47304735
47314736 if ( shouldRefresh ) {
47324737 responseInfo . keepIndicators = true
4733- location . reload ( )
4738+ htmx . location . reload ( )
47344739 return
47354740 }
47364741
0 commit comments