Skip to content

Commit 49d6aa3

Browse files
committed
prep 2.0.8 release
1 parent a6c3323 commit 49d6aa3

File tree

20 files changed

+128
-74
lines changed

20 files changed

+128
-74
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ By removing these arbitrary constraints htmx completes HTML as a
3232
## quick start
3333

3434
```html
35-
<script src="https://cdn.jsdelivr.net/npm/[email protected].7/dist/htmx.min.js"></script>
35+
<script src="https://cdn.jsdelivr.net/npm/[email protected].8/dist/htmx.min.js"></script>
3636
<!-- have a button POST a click via AJAX -->
3737
<button hx-post="/clicked" hx-swap="outerHTML">
3838
Click Me

dist/htmx.amd.js

Lines changed: 26 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -281,7 +281,7 @@ var htmx = (function() {
281281
*/
282282
historyRestoreAsHxRequest: true,
283283
/**
284-
* Weather to report input validation errors to the end user and update focus to the first input that fails validation.
284+
* Whether to report input validation errors to the end user and update focus to the first input that fails validation.
285285
* This should always be enabled as this matches default browser form submit behaviour
286286
* @type boolean
287287
* @default false
@@ -297,7 +297,7 @@ var htmx = (function() {
297297
location,
298298
/** @type {typeof internalEval} */
299299
_: null,
300-
version: '2.0.7'
300+
version: '2.0.8'
301301
}
302302
// Tsc madness part 2
303303
htmx.onLoad = onLoadHelper
@@ -526,6 +526,9 @@ var htmx = (function() {
526526
* @returns {Document}
527527
*/
528528
function parseHTML(resp) {
529+
if ('parseHTMLUnsafe' in Document) {
530+
return Document.parseHTMLUnsafe(resp)
531+
}
529532
const parser = new DOMParser()
530533
return parser.parseFromString(resp, 'text/html')
531534
}
@@ -3127,7 +3130,7 @@ var htmx = (function() {
31273130
//= ===================================================================
31283131
// History Support
31293132
//= ===================================================================
3130-
let currentPathForHistory = location.pathname + location.search
3133+
let currentPathForHistory
31313134

31323135
/**
31333136
* @param {string} path
@@ -3139,6 +3142,8 @@ var htmx = (function() {
31393142
}
31403143
}
31413144

3145+
setCurrentPathForHistory(location.pathname + location.search)
3146+
31423147
/**
31433148
* @returns {Element}
31443149
*/
@@ -4074,7 +4079,10 @@ var htmx = (function() {
40744079
targetOverride: resolvedTarget,
40754080
swapOverride: context.swap,
40764081
select: context.select,
4077-
returnPromise: true
4082+
returnPromise: true,
4083+
push: context.push,
4084+
replace: context.replace,
4085+
selectOOB: context.selectOOB
40784086
})
40794087
}
40804088
} else {
@@ -4689,8 +4697,8 @@ var htmx = (function() {
46894697
const requestPath = responseInfo.pathInfo.finalRequestPath
46904698
const responsePath = responseInfo.pathInfo.responsePath
46914699

4692-
const pushUrl = getClosestAttributeValue(elt, 'hx-push-url')
4693-
const replaceUrl = getClosestAttributeValue(elt, 'hx-replace-url')
4700+
const pushUrl = responseInfo.etc.push || getClosestAttributeValue(elt, 'hx-push-url')
4701+
const replaceUrl = responseInfo.etc.replace || getClosestAttributeValue(elt, 'hx-replace-url')
46944702
const elementIsBoosted = getInternalData(elt).boosted
46954703

46964704
let saveType = null
@@ -4809,19 +4817,17 @@ var htmx = (function() {
48094817
}
48104818

48114819
if (hasHeader(xhr, /HX-Location:/i)) {
4812-
saveCurrentPageToHistory()
48134820
let redirectPath = xhr.getResponseHeader('HX-Location')
4814-
/** @type {HtmxAjaxHelperContext&{path:string}} */
4815-
var redirectSwapSpec
4821+
/** @type {HtmxAjaxHelperContext&{path?:string}} */
4822+
var redirectSwapSpec = {}
48164823
if (redirectPath.indexOf('{') === 0) {
48174824
redirectSwapSpec = parseJSON(redirectPath)
48184825
// what's the best way to throw an error if the user didn't include this
48194826
redirectPath = redirectSwapSpec.path
48204827
delete redirectSwapSpec.path
48214828
}
4822-
ajaxHelper('get', redirectPath, redirectSwapSpec).then(function() {
4823-
pushUrlIntoHistory(redirectPath)
4824-
})
4829+
redirectSwapSpec.push = redirectSwapSpec.push || 'true'
4830+
ajaxHelper('get', redirectPath, redirectSwapSpec)
48254831
return
48264832
}
48274833

@@ -4920,7 +4926,7 @@ var htmx = (function() {
49204926
selectOverride = xhr.getResponseHeader('HX-Reselect')
49214927
}
49224928

4923-
const selectOOB = getClosestAttributeValue(elt, 'hx-select-oob')
4929+
const selectOOB = etc.selectOOB || getClosestAttributeValue(elt, 'hx-select-oob')
49244930
const select = getClosestAttributeValue(elt, 'hx-select')
49254931

49264932
swap(target, serverResponse, swapSpec, {
@@ -5119,7 +5125,7 @@ var htmx = (function() {
51195125
"[hx-trigger='restored'],[data-hx-trigger='restored']"
51205126
)
51215127
body.addEventListener('htmx:abort', function(evt) {
5122-
const target = evt.target
5128+
const target = (/** @type {CustomEvent} */(evt)).detail.elt || evt.target
51235129
const internalData = getInternalData(target)
51245130
if (internalData && internalData.xhr) {
51255131
internalData.xhr.abort()
@@ -5239,6 +5245,9 @@ var htmx = (function() {
52395245
* @property {Object|FormData} [values]
52405246
* @property {Record<string,string>} [headers]
52415247
* @property {string} [select]
5248+
* @property {string} [push]
5249+
* @property {string} [replace]
5250+
* @property {string} [selectOOB]
52425251
*/
52435252

52445253
/**
@@ -5285,6 +5294,9 @@ var htmx = (function() {
52855294
* @property {Object|FormData} [values]
52865295
* @property {boolean} [credentials]
52875296
* @property {number} [timeout]
5297+
* @property {string} [push]
5298+
* @property {string} [replace]
5299+
* @property {string} [selectOOB]
52885300
*/
52895301

52905302
/**

dist/htmx.cjs.js

Lines changed: 26 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -280,7 +280,7 @@ var htmx = (function() {
280280
*/
281281
historyRestoreAsHxRequest: true,
282282
/**
283-
* Weather to report input validation errors to the end user and update focus to the first input that fails validation.
283+
* Whether to report input validation errors to the end user and update focus to the first input that fails validation.
284284
* This should always be enabled as this matches default browser form submit behaviour
285285
* @type boolean
286286
* @default false
@@ -296,7 +296,7 @@ var htmx = (function() {
296296
location,
297297
/** @type {typeof internalEval} */
298298
_: null,
299-
version: '2.0.7'
299+
version: '2.0.8'
300300
}
301301
// Tsc madness part 2
302302
htmx.onLoad = onLoadHelper
@@ -525,6 +525,9 @@ var htmx = (function() {
525525
* @returns {Document}
526526
*/
527527
function parseHTML(resp) {
528+
if ('parseHTMLUnsafe' in Document) {
529+
return Document.parseHTMLUnsafe(resp)
530+
}
528531
const parser = new DOMParser()
529532
return parser.parseFromString(resp, 'text/html')
530533
}
@@ -3126,7 +3129,7 @@ var htmx = (function() {
31263129
//= ===================================================================
31273130
// History Support
31283131
//= ===================================================================
3129-
let currentPathForHistory = location.pathname + location.search
3132+
let currentPathForHistory
31303133

31313134
/**
31323135
* @param {string} path
@@ -3138,6 +3141,8 @@ var htmx = (function() {
31383141
}
31393142
}
31403143

3144+
setCurrentPathForHistory(location.pathname + location.search)
3145+
31413146
/**
31423147
* @returns {Element}
31433148
*/
@@ -4073,7 +4078,10 @@ var htmx = (function() {
40734078
targetOverride: resolvedTarget,
40744079
swapOverride: context.swap,
40754080
select: context.select,
4076-
returnPromise: true
4081+
returnPromise: true,
4082+
push: context.push,
4083+
replace: context.replace,
4084+
selectOOB: context.selectOOB
40774085
})
40784086
}
40794087
} else {
@@ -4688,8 +4696,8 @@ var htmx = (function() {
46884696
const requestPath = responseInfo.pathInfo.finalRequestPath
46894697
const responsePath = responseInfo.pathInfo.responsePath
46904698

4691-
const pushUrl = getClosestAttributeValue(elt, 'hx-push-url')
4692-
const replaceUrl = getClosestAttributeValue(elt, 'hx-replace-url')
4699+
const pushUrl = responseInfo.etc.push || getClosestAttributeValue(elt, 'hx-push-url')
4700+
const replaceUrl = responseInfo.etc.replace || getClosestAttributeValue(elt, 'hx-replace-url')
46934701
const elementIsBoosted = getInternalData(elt).boosted
46944702

46954703
let saveType = null
@@ -4808,19 +4816,17 @@ var htmx = (function() {
48084816
}
48094817

48104818
if (hasHeader(xhr, /HX-Location:/i)) {
4811-
saveCurrentPageToHistory()
48124819
let redirectPath = xhr.getResponseHeader('HX-Location')
4813-
/** @type {HtmxAjaxHelperContext&{path:string}} */
4814-
var redirectSwapSpec
4820+
/** @type {HtmxAjaxHelperContext&{path?:string}} */
4821+
var redirectSwapSpec = {}
48154822
if (redirectPath.indexOf('{') === 0) {
48164823
redirectSwapSpec = parseJSON(redirectPath)
48174824
// what's the best way to throw an error if the user didn't include this
48184825
redirectPath = redirectSwapSpec.path
48194826
delete redirectSwapSpec.path
48204827
}
4821-
ajaxHelper('get', redirectPath, redirectSwapSpec).then(function() {
4822-
pushUrlIntoHistory(redirectPath)
4823-
})
4828+
redirectSwapSpec.push = redirectSwapSpec.push || 'true'
4829+
ajaxHelper('get', redirectPath, redirectSwapSpec)
48244830
return
48254831
}
48264832

@@ -4919,7 +4925,7 @@ var htmx = (function() {
49194925
selectOverride = xhr.getResponseHeader('HX-Reselect')
49204926
}
49214927

4922-
const selectOOB = getClosestAttributeValue(elt, 'hx-select-oob')
4928+
const selectOOB = etc.selectOOB || getClosestAttributeValue(elt, 'hx-select-oob')
49234929
const select = getClosestAttributeValue(elt, 'hx-select')
49244930

49254931
swap(target, serverResponse, swapSpec, {
@@ -5118,7 +5124,7 @@ var htmx = (function() {
51185124
"[hx-trigger='restored'],[data-hx-trigger='restored']"
51195125
)
51205126
body.addEventListener('htmx:abort', function(evt) {
5121-
const target = evt.target
5127+
const target = (/** @type {CustomEvent} */(evt)).detail.elt || evt.target
51225128
const internalData = getInternalData(target)
51235129
if (internalData && internalData.xhr) {
51245130
internalData.xhr.abort()
@@ -5238,6 +5244,9 @@ var htmx = (function() {
52385244
* @property {Object|FormData} [values]
52395245
* @property {Record<string,string>} [headers]
52405246
* @property {string} [select]
5247+
* @property {string} [push]
5248+
* @property {string} [replace]
5249+
* @property {string} [selectOOB]
52415250
*/
52425251

52435252
/**
@@ -5284,6 +5293,9 @@ var htmx = (function() {
52845293
* @property {Object|FormData} [values]
52855294
* @property {boolean} [credentials]
52865295
* @property {number} [timeout]
5296+
* @property {string} [push]
5297+
* @property {string} [replace]
5298+
* @property {string} [selectOOB]
52875299
*/
52885300

52895301
/**

dist/htmx.esm.d.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,9 @@ export type HtmxAjaxHelperContext = {
6060
values?: any | FormData;
6161
headers?: Record<string, string>;
6262
select?: string;
63+
push?: string;
64+
replace?: string;
65+
selectOOB?: string;
6366
};
6467
export type HtmxRequestConfig = {
6568
boosted: boolean;
@@ -111,6 +114,9 @@ export type HtmxAjaxEtc = {
111114
values?: any | FormData;
112115
credentials?: boolean;
113116
timeout?: number;
117+
push?: string;
118+
replace?: string;
119+
selectOOB?: string;
114120
};
115121
export type HtmxResponseHandlingConfig = {
116122
code?: string;

0 commit comments

Comments
 (0)