@@ -4054,7 +4054,8 @@ var htmx = (function() {
40544054 swapOverride : context . swap ,
40554055 select : context . select ,
40564056 returnPromise : true ,
4057- pushUrl : context . pushUrl
4057+ push : context . push ,
4058+ replace : context . replace
40584059 } )
40594060 }
40604061 } else {
@@ -4633,82 +4634,39 @@ var htmx = (function() {
46334634 * @return {HtmxHistoryUpdate }
46344635 */
46354636 function determineHistoryUpdates ( elt , responseInfo ) {
4636- const xhr = responseInfo . xhr
4637+ const { xhr, pathInfo , etc } = responseInfo
46374638
4638- //= ==========================================
4639- // First consult response headers
4640- //= ==========================================
4641- let pathFromHeaders = null
4642- let typeFromHeaders = null
4643- if ( hasHeader ( xhr , / H X - P u s h : / i) ) {
4644- pathFromHeaders = xhr . getResponseHeader ( 'HX-Push' )
4645- typeFromHeaders = 'push'
4646- } else if ( hasHeader ( xhr , / H X - P u s h - U r l : / i) ) {
4647- pathFromHeaders = xhr . getResponseHeader ( 'HX-Push-Url' )
4648- typeFromHeaders = 'push'
4649- } else if ( hasHeader ( xhr , / H X - R e p l a c e - U r l : / i) ) {
4650- pathFromHeaders = xhr . getResponseHeader ( 'HX-Replace-Url' )
4651- typeFromHeaders = 'replace'
4652- }
4639+ let push = xhr . getResponseHeader ( 'HX-Push' ) || xhr . getResponseHeader ( 'HX-Push-Url' )
4640+ let replace = xhr . getResponseHeader ( 'HX-Replace-Url' )
46534641
46544642 // if there was a response header, that has priority
4655- if ( pathFromHeaders ) {
4656- if ( pathFromHeaders === 'false' ) {
4657- return { }
4658- } else {
4659- return {
4660- type : typeFromHeaders ,
4661- path : pathFromHeaders
4662- }
4643+ if ( ! push && ! replace ) {
4644+ // Next resolve via DOM values
4645+ push = getClosestAttributeValue ( elt , 'hx-push-url' ) || etc . push
4646+ replace = getClosestAttributeValue ( elt , 'hx-replace-url' ) || etc . replace
4647+ if ( ! push && ! replace && getInternalData ( elt ) . boosted ) {
4648+ push = 'true'
46634649 }
46644650 }
46654651
4666- //= ==========================================
4667- // Next resolve via DOM values
4668- //= ==========================================
4669- const requestPath = responseInfo . pathInfo . finalRequestPath
4670- const responsePath = responseInfo . pathInfo . responsePath
4671-
4672- const pushUrl = getClosestAttributeValue ( elt , 'hx-push-url' ) || responseInfo . etc . pushUrl
4673- const replaceUrl = getClosestAttributeValue ( elt , 'hx-replace-url' )
4674- const elementIsBoosted = getInternalData ( elt ) . boosted
4675-
4676- let saveType = null
4677- let path = null
4678-
4679- if ( pushUrl ) {
4680- saveType = 'push'
4681- path = pushUrl
4682- } else if ( replaceUrl ) {
4683- saveType = 'replace'
4684- path = replaceUrl
4685- } else if ( elementIsBoosted ) {
4686- saveType = 'push'
4687- path = responsePath || requestPath // if there is no response path, go with the original request path
4652+ let path = push || replace
4653+ // unset or false indicates no push, return empty object
4654+ if ( ! path || path === 'false' ) {
4655+ return { }
46884656 }
46894657
4690- if ( path ) {
4691- // false indicates no push, return empty object
4692- if ( path === 'false' ) {
4693- return { }
4694- }
4695-
4696- // true indicates we want to follow wherever the server ended up sending us
4697- if ( path === 'true' ) {
4698- path = responsePath || requestPath // if there is no response path, go with the original request path
4699- }
4700-
4701- // restore any anchor associated with the request
4702- if ( responseInfo . pathInfo . anchor && path . indexOf ( '#' ) === - 1 ) {
4703- path = path + '#' + responseInfo . pathInfo . anchor
4704- }
4658+ // true indicates we want to follow wherever the server ended up sending us
4659+ if ( path === 'true' ) {
4660+ path = pathInfo . responsePath || pathInfo . finalRequestPath // if there is no response path, go with the original request path
4661+ }
4662+ // restore any anchor associated with the request
4663+ if ( pathInfo . anchor && path . indexOf ( '#' ) === - 1 ) {
4664+ path = path + '#' + pathInfo . anchor
4665+ }
47054666
4706- return {
4707- type : saveType ,
4708- path
4709- }
4710- } else {
4711- return { }
4667+ return {
4668+ type : push ? 'push' : 'replace' ,
4669+ path
47124670 }
47134671 }
47144672
@@ -4798,7 +4756,7 @@ var htmx = (function() {
47984756 redirectPath = redirectSwapSpec . path
47994757 delete redirectSwapSpec . path
48004758 }
4801- redirectSwapSpec . pushUrl = redirectSwapSpec . pushUrl || 'true'
4759+ redirectSwapSpec . push = redirectSwapSpec . push || 'true'
48024760 ajaxHelper ( 'get' , redirectPath , redirectSwapSpec )
48034761 return
48044762 }
@@ -5215,7 +5173,8 @@ var htmx = (function() {
52155173 * @property {Object|FormData } [values]
52165174 * @property {Record<string,string> } [headers]
52175175 * @property {string } [select]
5218- * @property {string } [pushUrl]
5176+ * @property {string } [push]
5177+ * @property {string } [replace]
52195178 */
52205179
52215180/**
@@ -5262,7 +5221,8 @@ var htmx = (function() {
52625221 * @property {Object|FormData } [values]
52635222 * @property {boolean } [credentials]
52645223 * @property {number } [timeout]
5265- * @property {string } [pushUrl]
5224+ * @property {string } [push]
5225+ * @property {string } [replace]
52665226 */
52675227
52685228/**
0 commit comments