mirror of
https://github.com/bigskysoftware/htmx.git
synced 2025-10-02 07:21:05 +00:00
Add historyRestoreAsHxRequest config to optionally disable hx-request header from history restore requests (#3278)
* Added Config to optionally disable the breaking HX-Request change made recently * fix broken resolved conflict
This commit is contained in:
parent
db8e5e03cb
commit
5520566fc3
13
src/htmx.js
13
src/htmx.js
@ -271,7 +271,14 @@ var htmx = (function() {
|
|||||||
* @type boolean
|
* @type boolean
|
||||||
* @default true
|
* @default true
|
||||||
*/
|
*/
|
||||||
allowNestedOobSwaps: true
|
allowNestedOobSwaps: true,
|
||||||
|
/**
|
||||||
|
* Whether to treat history cache miss full page relaod requests as a "HX-Request" by returning this response header
|
||||||
|
* This should always be disabled when using HX-Request header to optionally return partial responses
|
||||||
|
* @type boolean
|
||||||
|
* @default true
|
||||||
|
*/
|
||||||
|
historyRestoreAsHxRequest: true
|
||||||
},
|
},
|
||||||
/** @type {typeof parseInterval} */
|
/** @type {typeof parseInterval} */
|
||||||
parseInterval: null,
|
parseInterval: null,
|
||||||
@ -3193,7 +3200,9 @@ var htmx = (function() {
|
|||||||
const details = { path, xhr: request }
|
const details = { path, xhr: request }
|
||||||
triggerEvent(getDocument().body, 'htmx:historyCacheMiss', details)
|
triggerEvent(getDocument().body, 'htmx:historyCacheMiss', details)
|
||||||
request.open('GET', path, true)
|
request.open('GET', path, true)
|
||||||
request.setRequestHeader('HX-Request', 'true')
|
if (htmx.config.historyRestoreAsHxRequest) {
|
||||||
|
request.setRequestHeader('HX-Request', 'true')
|
||||||
|
}
|
||||||
request.setRequestHeader('HX-History-Restore-Request', 'true')
|
request.setRequestHeader('HX-History-Restore-Request', 'true')
|
||||||
request.setRequestHeader('HX-Current-URL', location.href)
|
request.setRequestHeader('HX-Current-URL', location.href)
|
||||||
request.onload = function() {
|
request.onload = function() {
|
||||||
|
@ -401,7 +401,7 @@ describe('Core htmx AJAX headers', function() {
|
|||||||
htmx.location = window.location
|
htmx.location = window.location
|
||||||
})
|
})
|
||||||
|
|
||||||
it('request to restore history should include the HX-Request header', function() {
|
it('request to restore history should include the HX-Request header when historyRestoreAsHxRequest true', function() {
|
||||||
this.server.respondWith('GET', '/test', function(xhr) {
|
this.server.respondWith('GET', '/test', function(xhr) {
|
||||||
xhr.requestHeaders['HX-Request'].should.be.equal('true')
|
xhr.requestHeaders['HX-Request'].should.be.equal('true')
|
||||||
xhr.respond(200, {}, '')
|
xhr.respond(200, {}, '')
|
||||||
@ -410,6 +410,17 @@ describe('Core htmx AJAX headers', function() {
|
|||||||
this.server.respond()
|
this.server.respond()
|
||||||
})
|
})
|
||||||
|
|
||||||
|
it('request to restore history should not include the HX-Request header when historyRestoreAsHxRequest false', function() {
|
||||||
|
htmx.config.historyRestoreAsHxRequest = false
|
||||||
|
this.server.respondWith('GET', '/test', function(xhr) {
|
||||||
|
should.equal(xhr.requestHeaders['HX-Request'], undefined)
|
||||||
|
xhr.respond(200, {}, '')
|
||||||
|
})
|
||||||
|
htmx._('loadHistoryFromServer')('/test')
|
||||||
|
this.server.respond()
|
||||||
|
htmx.config.historyRestoreAsHxRequest = true
|
||||||
|
})
|
||||||
|
|
||||||
it('request history from server with error status code throws error event', function() {
|
it('request history from server with error status code throws error event', function() {
|
||||||
this.server.respondWith('GET', '/test', function(xhr) {
|
this.server.respondWith('GET', '/test', function(xhr) {
|
||||||
xhr.requestHeaders['HX-Request'].should.be.equal('true')
|
xhr.requestHeaders['HX-Request'].should.be.equal('true')
|
||||||
|
@ -138,6 +138,7 @@ Note that using a [meta tag](@/docs.md#config) is the preferred mechanism for se
|
|||||||
* `triggerSpecsCache:null` - object: the cache to store evaluated trigger specifications into, improving parsing performance at the cost of more memory usage. You may define a simple object to use a never-clearing cache, or implement your own system using a [proxy object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Proxy)
|
* `triggerSpecsCache:null` - object: the cache to store evaluated trigger specifications into, improving parsing performance at the cost of more memory usage. You may define a simple object to use a never-clearing cache, or implement your own system using a [proxy object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Proxy)
|
||||||
* `htmx.config.responseHandling:[...]` - HtmxResponseHandlingConfig[]: the default [Response Handling](@/docs.md#response-handling) behavior for response status codes can be configured here to either swap or error
|
* `htmx.config.responseHandling:[...]` - HtmxResponseHandlingConfig[]: the default [Response Handling](@/docs.md#response-handling) behavior for response status codes can be configured here to either swap or error
|
||||||
* `htmx.config.allowNestedOobSwaps:true` - boolean: whether to process OOB swaps on elements that are nested within the main response element. See [Nested OOB Swaps](@/attributes/hx-swap-oob.md#nested-oob-swaps).
|
* `htmx.config.allowNestedOobSwaps:true` - boolean: whether to process OOB swaps on elements that are nested within the main response element. See [Nested OOB Swaps](@/attributes/hx-swap-oob.md#nested-oob-swaps).
|
||||||
|
* `htmx.config.historyRestoreAsHxRequest:true` - Whether to treat history cache miss full page relaod requests as a "HX-Request" by returning this response header. This should always be disabled when using HX-Request header to optionally return partial responses
|
||||||
|
|
||||||
##### Example
|
##### Example
|
||||||
|
|
||||||
|
@ -857,8 +857,9 @@ It then does the swap and pushes a new location onto the history stack.
|
|||||||
When a user hits the back button, htmx will retrieve the old content from storage and swap it back into the target,
|
When a user hits the back button, htmx will retrieve the old content from storage and swap it back into the target,
|
||||||
simulating "going back" to the previous state. If the location is not found in the cache, htmx will make an ajax
|
simulating "going back" to the previous state. If the location is not found in the cache, htmx will make an ajax
|
||||||
request to the given URL, with the header `HX-History-Restore-Request` set to true, and expects back the HTML needed
|
request to the given URL, with the header `HX-History-Restore-Request` set to true, and expects back the HTML needed
|
||||||
for the entire page. Alternatively, if the `htmx.config.refreshOnHistoryMiss` config variable is set to true, it will
|
for the entire page. You should always set `htmx.config.historyRestoreAsHxRequest` to false to prevent the `HX-Request` header
|
||||||
issue a hard browser refresh.
|
which can then be safely used to respond with partials. Alternatively, if the `htmx.config.refreshOnHistoryMiss` config variable
|
||||||
|
is set to true, it will issue a hard browser refresh.
|
||||||
|
|
||||||
**NOTE:** If you push a URL into the history, you **must** be able to navigate to that URL and get a full page back!
|
**NOTE:** If you push a URL into the history, you **must** be able to navigate to that URL and get a full page back!
|
||||||
A user could copy and paste the URL into an email, or new tab. Additionally, htmx will need the entire page when restoring
|
A user could copy and paste the URL into an email, or new tab. Additionally, htmx will need the entire page when restoring
|
||||||
@ -1019,7 +1020,7 @@ htmx includes a number of useful headers in requests:
|
|||||||
| `HX-Current-URL` | the current URL of the browser
|
| `HX-Current-URL` | the current URL of the browser
|
||||||
| `HX-History-Restore-Request` | "true" if the request is for history restoration after a miss in the local history cache
|
| `HX-History-Restore-Request` | "true" if the request is for history restoration after a miss in the local history cache
|
||||||
| `HX-Prompt` | the user response to an [hx-prompt](@/attributes/hx-prompt.md)
|
| `HX-Prompt` | the user response to an [hx-prompt](@/attributes/hx-prompt.md)
|
||||||
| `HX-Request` | always "true"
|
| `HX-Request` | always "true" except on history restore requests if `htmx.config.historyRestoreAsHxRequest' disabled
|
||||||
| `HX-Target` | the `id` of the target element if it exists
|
| `HX-Target` | the `id` of the target element if it exists
|
||||||
| `HX-Trigger-Name` | the `name` of the triggered element if it exists
|
| `HX-Trigger-Name` | the `name` of the triggered element if it exists
|
||||||
| `HX-Trigger` | the `id` of the triggered element if it exists
|
| `HX-Trigger` | the `id` of the triggered element if it exists
|
||||||
@ -1527,7 +1528,8 @@ response HTTP header. For example, if your server renders the full HTML when the
|
|||||||
`HX-Request` header is missing or `false`, and it renders a fragment of that HTML
|
`HX-Request` header is missing or `false`, and it renders a fragment of that HTML
|
||||||
when `HX-Request: true`, you need to add `Vary: HX-Request`. That causes the cache to be
|
when `HX-Request: true`, you need to add `Vary: HX-Request`. That causes the cache to be
|
||||||
keyed based on a composite of the response URL and the `HX-Request` request header —
|
keyed based on a composite of the response URL and the `HX-Request` request header —
|
||||||
rather than being based just on the response URL.
|
rather than being based just on the response URL. Always disable `htmx.config.historyRestoreAsHxRequest`
|
||||||
|
so that these history full HTML requests are not cached with partial fragment responses.
|
||||||
|
|
||||||
If you are unable (or unwilling) to use the `Vary` header, you can alternatively set the configuration parameter
|
If you are unable (or unwilling) to use the `Vary` header, you can alternatively set the configuration parameter
|
||||||
`getCacheBusterParam` to `true`. If this configuration variable is set, htmx will include a cache-busting parameter
|
`getCacheBusterParam` to `true`. If this configuration variable is set, htmx will include a cache-busting parameter
|
||||||
@ -1661,44 +1663,44 @@ listed below:
|
|||||||
|
|
||||||
<div class="info-table">
|
<div class="info-table">
|
||||||
|
|
||||||
| Config Variable | Info |
|
| Config Variable | Info |
|
||||||
|---------------------------------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
|
|----------------------------------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
|
||||||
| `htmx.config.historyEnabled` | defaults to `true`, really only useful for testing |
|
| `htmx.config.historyEnabled` | defaults to `true`, really only useful for testing |
|
||||||
| `htmx.config.historyCacheSize` | defaults to 10 |
|
| `htmx.config.historyCacheSize` | defaults to 10 |
|
||||||
| `htmx.config.refreshOnHistoryMiss` | defaults to `false`, if set to `true` htmx will issue a full page refresh on history misses rather than use an AJAX request |
|
| `htmx.config.refreshOnHistoryMiss` | defaults to `false`, if set to `true` htmx will issue a full page refresh on history misses rather than use an AJAX request |
|
||||||
| `htmx.config.defaultSwapStyle` | defaults to `innerHTML` |
|
| `htmx.config.defaultSwapStyle` | defaults to `innerHTML` |
|
||||||
| `htmx.config.defaultSwapDelay` | defaults to 0 |
|
| `htmx.config.defaultSwapDelay` | defaults to 0 |
|
||||||
| `htmx.config.defaultSettleDelay` | defaults to 20 |
|
| `htmx.config.defaultSettleDelay` | defaults to 20 |
|
||||||
| `htmx.config.includeIndicatorStyles` | defaults to `true` (determines if the indicator styles are loaded) |
|
| `htmx.config.includeIndicatorStyles` | defaults to `true` (determines if the indicator styles are loaded) |
|
||||||
| `htmx.config.indicatorClass` | defaults to `htmx-indicator` |
|
| `htmx.config.indicatorClass` | defaults to `htmx-indicator` |
|
||||||
| `htmx.config.requestClass` | defaults to `htmx-request` |
|
| `htmx.config.requestClass` | defaults to `htmx-request` |
|
||||||
| `htmx.config.addedClass` | defaults to `htmx-added` |
|
| `htmx.config.addedClass` | defaults to `htmx-added` |
|
||||||
| `htmx.config.settlingClass` | defaults to `htmx-settling` |
|
| `htmx.config.settlingClass` | defaults to `htmx-settling` |
|
||||||
| `htmx.config.swappingClass` | defaults to `htmx-swapping` |
|
| `htmx.config.swappingClass` | defaults to `htmx-swapping` |
|
||||||
| `htmx.config.allowEval` | defaults to `true`, can be used to disable htmx's use of eval for certain features (e.g. trigger filters) |
|
| `htmx.config.allowEval` | defaults to `true`, can be used to disable htmx's use of eval for certain features (e.g. trigger filters) |
|
||||||
| `htmx.config.allowScriptTags` | defaults to `true`, determines if htmx will process script tags found in new content |
|
| `htmx.config.allowScriptTags` | defaults to `true`, determines if htmx will process script tags found in new content |
|
||||||
| `htmx.config.inlineScriptNonce` | defaults to `''`, meaning that no nonce will be added to inline scripts |
|
| `htmx.config.inlineScriptNonce` | defaults to `''`, meaning that no nonce will be added to inline scripts |
|
||||||
| `htmx.config.attributesToSettle` | defaults to `["class", "style", "width", "height"]`, the attributes to settle during the settling phase |
|
| `htmx.config.attributesToSettle` | defaults to `["class", "style", "width", "height"]`, the attributes to settle during the settling phase |
|
||||||
| `htmx.config.inlineStyleNonce` | defaults to `''`, meaning that no nonce will be added to inline styles |
|
| `htmx.config.inlineStyleNonce` | defaults to `''`, meaning that no nonce will be added to inline styles |
|
||||||
| `htmx.config.useTemplateFragments` | defaults to `false`, HTML template tags for parsing content from the server (not IE11 compatible!) |
|
| `htmx.config.useTemplateFragments` | defaults to `false`, HTML template tags for parsing content from the server (not IE11 compatible!) |
|
||||||
| `htmx.config.wsReconnectDelay` | defaults to `full-jitter` |
|
| `htmx.config.wsReconnectDelay` | defaults to `full-jitter` |
|
||||||
| `htmx.config.wsBinaryType` | defaults to `blob`, the [type of binary data](https://developer.mozilla.org/docs/Web/API/WebSocket/binaryType) being received over the WebSocket connection |
|
| `htmx.config.wsBinaryType` | defaults to `blob`, the [type of binary data](https://developer.mozilla.org/docs/Web/API/WebSocket/binaryType) being received over the WebSocket connection |
|
||||||
| `htmx.config.disableSelector` | defaults to `[hx-disable], [data-hx-disable]`, htmx will not process elements with this attribute on it or a parent |
|
| `htmx.config.disableSelector` | defaults to `[hx-disable], [data-hx-disable]`, htmx will not process elements with this attribute on it or a parent |
|
||||||
| `htmx.config.withCredentials` | defaults to `false`, allow cross-site Access-Control requests using credentials such as cookies, authorization headers or TLS client certificates |
|
| `htmx.config.withCredentials` | defaults to `false`, allow cross-site Access-Control requests using credentials such as cookies, authorization headers or TLS client certificates |
|
||||||
| `htmx.config.timeout` | defaults to 0, the number of milliseconds a request can take before automatically being terminated |
|
| `htmx.config.timeout` | defaults to 0, the number of milliseconds a request can take before automatically being terminated |
|
||||||
| `htmx.config.scrollBehavior` | defaults to 'instant', the scroll behavior when using the [show](@/attributes/hx-swap.md#scrolling-scroll-show) modifier with `hx-swap`. The allowed values are `instant` (scrolling should happen instantly in a single jump), `smooth` (scrolling should animate smoothly) and `auto` (scroll behavior is determined by the computed value of [scroll-behavior](https://developer.mozilla.org/en-US/docs/Web/CSS/scroll-behavior)). |
|
| `htmx.config.scrollBehavior` | defaults to 'instant', the scroll behavior when using the [show](@/attributes/hx-swap.md#scrolling-scroll-show) modifier with `hx-swap`. The allowed values are `instant` (scrolling should happen instantly in a single jump), `smooth` (scrolling should animate smoothly) and `auto` (scroll behavior is determined by the computed value of [scroll-behavior](https://developer.mozilla.org/en-US/docs/Web/CSS/scroll-behavior)). |
|
||||||
| `htmx.config.defaultFocusScroll` | if the focused element should be scrolled into view, defaults to false and can be overridden using the [focus-scroll](@/attributes/hx-swap.md#focus-scroll) swap modifier. |
|
| `htmx.config.defaultFocusScroll` | if the focused element should be scrolled into view, defaults to false and can be overridden using the [focus-scroll](@/attributes/hx-swap.md#focus-scroll) swap modifier. |
|
||||||
| `htmx.config.getCacheBusterParam` | defaults to false, if set to true htmx will append the target element to the `GET` request in the format `org.htmx.cache-buster=targetElementId` |
|
| `htmx.config.getCacheBusterParam` | defaults to false, if set to true htmx will append the target element to the `GET` request in the format `org.htmx.cache-buster=targetElementId` |
|
||||||
| `htmx.config.globalViewTransitions` | if set to `true`, htmx will use the [View Transition](https://developer.mozilla.org/en-US/docs/Web/API/View_Transitions_API) API when swapping in new content. |
|
| `htmx.config.globalViewTransitions` | if set to `true`, htmx will use the [View Transition](https://developer.mozilla.org/en-US/docs/Web/API/View_Transitions_API) API when swapping in new content. |
|
||||||
| `htmx.config.methodsThatUseUrlParams` | defaults to `["get", "delete"]`, htmx will format requests with these methods by encoding their parameters in the URL, not the request body |
|
| `htmx.config.methodsThatUseUrlParams` | defaults to `["get", "delete"]`, htmx will format requests with these methods by encoding their parameters in the URL, not the request body |
|
||||||
| `htmx.config.selfRequestsOnly` | defaults to `true`, whether to only allow AJAX requests to the same domain as the current document |
|
| `htmx.config.selfRequestsOnly` | defaults to `true`, whether to only allow AJAX requests to the same domain as the current document |
|
||||||
| `htmx.config.ignoreTitle` | defaults to `false`, if set to `true` htmx will not update the title of the document when a `title` tag is found in new content |
|
| `htmx.config.ignoreTitle` | defaults to `false`, if set to `true` htmx will not update the title of the document when a `title` tag is found in new content |
|
||||||
| `htmx.config.disableInheritance` | disables attribute inheritance in htmx, which can then be overridden by the [`hx-inherit`](@/attributes/hx-inherit.md) attribute |
|
| `htmx.config.disableInheritance` | disables attribute inheritance in htmx, which can then be overridden by the [`hx-inherit`](@/attributes/hx-inherit.md) attribute |
|
||||||
| `htmx.config.scrollIntoViewOnBoost` | defaults to `true`, whether or not the target of a boosted element is scrolled into the viewport. If `hx-target` is omitted on a boosted element, the target defaults to `body`, causing the page to scroll to the top. |
|
| `htmx.config.scrollIntoViewOnBoost` | defaults to `true`, whether or not the target of a boosted element is scrolled into the viewport. If `hx-target` is omitted on a boosted element, the target defaults to `body`, causing the page to scroll to the top. |
|
||||||
| `htmx.config.triggerSpecsCache` | defaults to `null`, the cache to store evaluated trigger specifications into, improving parsing performance at the cost of more memory usage. You may define a simple object to use a never-clearing cache, or implement your own system using a [proxy object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Proxy) |
|
| `htmx.config.triggerSpecsCache` | defaults to `null`, the cache to store evaluated trigger specifications into, improving parsing performance at the cost of more memory usage. You may define a simple object to use a never-clearing cache, or implement your own system using a [proxy object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Proxy) |
|
||||||
| `htmx.config.responseHandling` | the default [Response Handling](@/docs.md#response-handling) behavior for response status codes can be configured here to either swap or error |
|
| `htmx.config.responseHandling` | the default [Response Handling](@/docs.md#response-handling) behavior for response status codes can be configured here to either swap or error |
|
||||||
| `htmx.config.allowNestedOobSwaps` | defaults to `true`, whether to process OOB swaps on elements that are nested within the main response element. See [Nested OOB Swaps](@/attributes/hx-swap-oob.md#nested-oob-swaps). |
|
| `htmx.config.allowNestedOobSwaps` | defaults to `true`, whether to process OOB swaps on elements that are nested within the main response element. See [Nested OOB Swaps](@/attributes/hx-swap-oob.md#nested-oob-swaps). |
|
||||||
|
| `htmx.config.historyRestoreAsHxRequest`| defaults to `true`, Whether to treat history cache miss full page relaod requests as a "HX-Request" by returning this response header. This should always be disabled when using HX-Request header to optionally return partial responses |
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
You can set them directly in javascript, or you can use a `meta` tag:
|
You can set them directly in javascript, or you can use a `meta` tag:
|
||||||
|
@ -218,42 +218,44 @@ listed below:
|
|||||||
|
|
||||||
<div class="info-table">
|
<div class="info-table">
|
||||||
|
|
||||||
| Config Variable | Info |
|
| Config Variable | Info |
|
||||||
|---------------------------------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
|
|----------------------------------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
|
||||||
| `htmx.config.historyEnabled` | defaults to `true`, really only useful for testing |
|
| `htmx.config.historyEnabled` | defaults to `true`, really only useful for testing |
|
||||||
| `htmx.config.historyCacheSize` | defaults to 10 |
|
| `htmx.config.historyCacheSize` | defaults to 10 |
|
||||||
| `htmx.config.refreshOnHistoryMiss` | defaults to `false`, if set to `true` htmx will issue a full page refresh on history misses rather than use an AJAX request |
|
| `htmx.config.refreshOnHistoryMiss` | defaults to `false`, if set to `true` htmx will issue a full page refresh on history misses rather than use an AJAX request |
|
||||||
| `htmx.config.defaultSwapStyle` | defaults to `innerHTML` |
|
| `htmx.config.defaultSwapStyle` | defaults to `innerHTML` |
|
||||||
| `htmx.config.defaultSwapDelay` | defaults to 0 |
|
| `htmx.config.defaultSwapDelay` | defaults to 0 |
|
||||||
| `htmx.config.defaultSettleDelay` | defaults to 20 |
|
| `htmx.config.defaultSettleDelay` | defaults to 20 |
|
||||||
| `htmx.config.includeIndicatorStyles` | defaults to `true` (determines if the indicator styles are loaded) |
|
| `htmx.config.includeIndicatorStyles` | defaults to `true` (determines if the indicator styles are loaded) |
|
||||||
| `htmx.config.indicatorClass` | defaults to `htmx-indicator` |
|
| `htmx.config.indicatorClass` | defaults to `htmx-indicator` |
|
||||||
| `htmx.config.requestClass` | defaults to `htmx-request` |
|
| `htmx.config.requestClass` | defaults to `htmx-request` |
|
||||||
| `htmx.config.addedClass` | defaults to `htmx-added` |
|
| `htmx.config.addedClass` | defaults to `htmx-added` |
|
||||||
| `htmx.config.settlingClass` | defaults to `htmx-settling` |
|
| `htmx.config.settlingClass` | defaults to `htmx-settling` |
|
||||||
| `htmx.config.swappingClass` | defaults to `htmx-swapping` |
|
| `htmx.config.swappingClass` | defaults to `htmx-swapping` |
|
||||||
| `htmx.config.allowEval` | defaults to `true`, can be used to disable htmx's use of eval for certain features (e.g. trigger filters) |
|
| `htmx.config.allowEval` | defaults to `true`, can be used to disable htmx's use of eval for certain features (e.g. trigger filters) |
|
||||||
| `htmx.config.allowScriptTags` | defaults to `true`, determines if htmx will process script tags found in new content |
|
| `htmx.config.allowScriptTags` | defaults to `true`, determines if htmx will process script tags found in new content |
|
||||||
| `htmx.config.inlineScriptNonce` | defaults to `''`, meaning that no nonce will be added to inline scripts |
|
| `htmx.config.inlineScriptNonce` | defaults to `''`, meaning that no nonce will be added to inline scripts |
|
||||||
| `htmx.config.inlineStyleNonce` | defaults to `''`, meaning that no nonce will be added to inline styles |
|
| `htmx.config.inlineStyleNonce` | defaults to `''`, meaning that no nonce will be added to inline styles |
|
||||||
| `htmx.config.attributesToSettle` | defaults to `["class", "style", "width", "height"]`, the attributes to settle during the settling phase |
|
| `htmx.config.attributesToSettle` | defaults to `["class", "style", "width", "height"]`, the attributes to settle during the settling phase |
|
||||||
| `htmx.config.wsReconnectDelay` | defaults to `full-jitter` |
|
| `htmx.config.wsReconnectDelay` | defaults to `full-jitter` |
|
||||||
| `htmx.config.wsBinaryType` | defaults to `blob`, the [the type of binary data](https://developer.mozilla.org/docs/Web/API/WebSocket/binaryType) being received over the WebSocket connection |
|
| `htmx.config.wsBinaryType` | defaults to `blob`, the [the type of binary data](https://developer.mozilla.org/docs/Web/API/WebSocket/binaryType) being received over the WebSocket connection |
|
||||||
| `htmx.config.disableSelector` | defaults to `[hx-disable], [data-hx-disable]`, htmx will not process elements with this attribute on it or a parent |
|
| `htmx.config.disableSelector` | defaults to `[hx-disable], [data-hx-disable]`, htmx will not process elements with this attribute on it or a parent |
|
||||||
| `htmx.config.disableInheritance` | defaults to `false`. If it is set to `true`, the inheritance of attributes is completely disabled and you can explicitly specify the inheritance with the [hx-inherit](@/attributes/hx-inherit.md) attribute.
|
| `htmx.config.disableInheritance` | defaults to `false`. If it is set to `true`, the inheritance of attributes is completely disabled and you can explicitly specify the inheritance with the [hx-inherit](@/attributes/hx-inherit.md) attribute.
|
||||||
| `htmx.config.withCredentials` | defaults to `false`, allow cross-site Access-Control requests using credentials such as cookies, authorization headers or TLS client certificates |
|
| `htmx.config.withCredentials` | defaults to `false`, allow cross-site Access-Control requests using credentials such as cookies, authorization headers or TLS client certificates |
|
||||||
| `htmx.config.timeout` | defaults to 0, the number of milliseconds a request can take before automatically being terminated |
|
| `htmx.config.timeout` | defaults to 0, the number of milliseconds a request can take before automatically being terminated |
|
||||||
| `htmx.config.scrollBehavior` | defaults to 'instant', the scroll behavior when using the [show](@/attributes/hx-swap.md#scrolling-scroll-show) modifier with `hx-swap`. The allowed values are `instant` (scrolling should happen instantly in a single jump), `smooth` (scrolling should animate smoothly) and `auto` (scroll behavior is determined by the computed value of [scroll-behavior](https://developer.mozilla.org/en-US/docs/Web/CSS/scroll-behavior)). |
|
| `htmx.config.scrollBehavior` | defaults to 'instant', the scroll behavior when using the [show](@/attributes/hx-swap.md#scrolling-scroll-show) modifier with `hx-swap`. The allowed values are `instant` (scrolling should happen instantly in a single jump), `smooth` (scrolling should animate smoothly) and `auto` (scroll behavior is determined by the computed value of [scroll-behavior](https://developer.mozilla.org/en-US/docs/Web/CSS/scroll-behavior)). |
|
||||||
| `htmx.config.defaultFocusScroll` | if the focused element should be scrolled into view, defaults to false and can be overridden using the [focus-scroll](@/attributes/hx-swap.md#focus-scroll) swap modifier. |
|
| `htmx.config.defaultFocusScroll` | if the focused element should be scrolled into view, defaults to false and can be overridden using the [focus-scroll](@/attributes/hx-swap.md#focus-scroll) swap modifier. |
|
||||||
| `htmx.config.getCacheBusterParam` | defaults to false, if set to true htmx will append the target element to the `GET` request in the format `org.htmx.cache-buster=targetElementId` |
|
| `htmx.config.getCacheBusterParam` | defaults to false, if set to true htmx will append the target element to the `GET` request in the format `org.htmx.cache-buster=targetElementId` |
|
||||||
| `htmx.config.globalViewTransitions` | if set to `true`, htmx will use the [View Transition](https://developer.mozilla.org/en-US/docs/Web/API/View_Transitions_API) API when swapping in new content. |
|
| `htmx.config.globalViewTransitions` | if set to `true`, htmx will use the [View Transition](https://developer.mozilla.org/en-US/docs/Web/API/View_Transitions_API) API when swapping in new content. |
|
||||||
| `htmx.config.methodsThatUseUrlParams` | defaults to `["get", "delete"]`, htmx will format requests with these methods by encoding their parameters in the URL, not the request body |
|
| `htmx.config.methodsThatUseUrlParams` | defaults to `["get", "delete"]`, htmx will format requests with these methods by encoding their parameters in the URL, not the request body |
|
||||||
| `htmx.config.selfRequestsOnly` | defaults to `true`, whether to only allow AJAX requests to the same domain as the current document |
|
| `htmx.config.selfRequestsOnly` | defaults to `true`, whether to only allow AJAX requests to the same domain as the current document |
|
||||||
| `htmx.config.ignoreTitle` | defaults to `false`, if set to `true` htmx will not update the title of the document when a `title` tag is found in new content |
|
| `htmx.config.ignoreTitle` | defaults to `false`, if set to `true` htmx will not update the title of the document when a `title` tag is found in new content |
|
||||||
| `htmx.config.scrollIntoViewOnBoost` | defaults to `true`, whether or not the target of a boosted element is scrolled into the viewport. If `hx-target` is omitted on a boosted element, the target defaults to `body`, causing the page to scroll to the top. |
|
| `htmx.config.scrollIntoViewOnBoost` | defaults to `true`, whether or not the target of a boosted element is scrolled into the viewport. If `hx-target` is omitted on a boosted element, the target defaults to `body`, causing the page to scroll to the top. |
|
||||||
| `htmx.config.triggerSpecsCache` | defaults to `null`, the cache to store evaluated trigger specifications into, improving parsing performance at the cost of more memory usage. You may define a simple object to use a never-clearing cache, or implement your own system using a [proxy object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Proxy) |
|
| `htmx.config.triggerSpecsCache` | defaults to `null`, the cache to store evaluated trigger specifications into, improving parsing performance at the cost of more memory usage. You may define a simple object to use a never-clearing cache, or implement your own system using a [proxy object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Proxy) |
|
||||||
| `htmx.config.responseHandling` | the default [Response Handling](@/docs.md#response-handling) behavior for response status codes can be configured here to either swap or error |
|
| `htmx.config.responseHandling` | the default [Response Handling](@/docs.md#response-handling) behavior for response status codes can be configured here to either swap or error |
|
||||||
| `htmx.config.allowNestedOobSwaps` | defaults to `true`, whether to process OOB swaps on elements that are nested within the main response element. See [Nested OOB Swaps](@/attributes/hx-swap-oob.md#nested-oob-swaps). |
|
| `htmx.config.allowNestedOobSwaps` | defaults to `true`, whether to process OOB swaps on elements that are nested within the main response element. See [Nested OOB Swaps](@/attributes/hx-swap-oob.md#nested-oob-swaps). |
|
||||||
|
| `htmx.config.historyRestoreAsHxRequest`| defaults to `true`, Whether to treat history cache miss full page relaod requests as a "HX-Request" by returning this response header. This should always be disabled when using HX-Request header to optionally return partial responses |
|
||||||
|
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user