mirror of
https://github.com/bigskysoftware/htmx.git
synced 2025-10-01 23:11:12 +00:00
flip defaults for 2.0
This commit is contained in:
parent
555522baaa
commit
5c42b3442b
@ -69,12 +69,12 @@ return (function () {
|
||||
wsBinaryType: 'blob',
|
||||
disableSelector: "[hx-disable], [data-hx-disable]",
|
||||
useTemplateFragments: false,
|
||||
scrollBehavior: 'smooth',
|
||||
scrollBehavior: 'instant',
|
||||
defaultFocusScroll: false,
|
||||
getCacheBusterParam: false,
|
||||
globalViewTransitions: false,
|
||||
methodsThatUseUrlParams: ["get"],
|
||||
selfRequestsOnly: false,
|
||||
methodsThatUseUrlParams: ["get", "delete"],
|
||||
selfRequestsOnly: true,
|
||||
ignoreTitle: false,
|
||||
scrollIntoViewOnBoost: true
|
||||
},
|
||||
|
@ -395,6 +395,7 @@ describe("Core htmx Events", function() {
|
||||
this.skip()
|
||||
return
|
||||
}
|
||||
htmx.config.selfRequestsOnly = false; // turn off self requests only
|
||||
var called = false;
|
||||
var handler = htmx.on("htmx:sendError", function (evt) {
|
||||
called = true;
|
||||
@ -405,6 +406,7 @@ describe("Core htmx Events", function() {
|
||||
setTimeout(function () {
|
||||
htmx.off("htmx:sendError", handler);
|
||||
should.equal(called, true);
|
||||
htmx.config.selfRequestsOnly = true; // restore self requests only
|
||||
done();
|
||||
}, 30);
|
||||
});
|
||||
|
@ -106,10 +106,12 @@ describe("security options", function() {
|
||||
btn.innerHTML.should.equal("Clicked a second time");
|
||||
})
|
||||
|
||||
it("can make egress cross site requests when htmx.config.selfRequestsOnly is enabled", function(done){
|
||||
it("can make egress cross site requests when htmx.config.selfRequestsOnly is disabled", function(done){
|
||||
this.timeout(4000)
|
||||
htmx.config.selfRequestsOnly = false;
|
||||
// should trigger send error, rather than reject
|
||||
var listener = htmx.on("htmx:sendError", function (){
|
||||
htmx.config.selfRequestsOnly = true;
|
||||
htmx.off("htmx:sendError", listener);
|
||||
done();
|
||||
});
|
||||
@ -122,9 +124,7 @@ describe("security options", function() {
|
||||
it("can't make egress cross site requests when htmx.config.selfRequestsOnly is enabled", function(done){
|
||||
this.timeout(4000)
|
||||
// should trigger send error, rather than reject
|
||||
htmx.config.selfRequestsOnly = true;
|
||||
var listener = htmx.on("htmx:invalidPath", function (){
|
||||
htmx.config.selfRequestsOnly = false;
|
||||
htmx.off("htmx:invalidPath", listener);
|
||||
done();
|
||||
})
|
||||
|
@ -171,6 +171,28 @@ window.htmx = require('htmx.org');
|
||||
|
||||
* Finally, rebuild your bundle
|
||||
|
||||
### htmx 1.x to 2.x Upgrade Guide
|
||||
|
||||
To upgrade to htmx 2.0 from htmx 1.0, you will need to do the following:
|
||||
|
||||
* If you are still using the legacy `hx-ws` and `hx-sse` attributes, please upgrade to the extension versions (available in 1.x)
|
||||
of those features
|
||||
* Default Changes
|
||||
* If you want to retain the 1.0 behavior of "smooth scrolling" by default, revert `htmx.config.scrollBehavior` to `'smooth'`
|
||||
* If you want `DELETE` requests to use a form-encoded body rather than parameters, revert
|
||||
`htmx.config.methodsThatUseUrlParams` to `["get"]` (it's a little crazy, but `DELETE`, according to the spec, should
|
||||
use request parameters.)
|
||||
* If you want to make cross-domain requests with htmx, revert `htmx.config.selfRequestsOnly` to `false`
|
||||
|
||||
here is a meta tag to revert to htmx 1.x defaults:
|
||||
|
||||
```html
|
||||
<meta name="htmx-config" content='{"scrollBehavior":"smooth", "methodsThatUseUrlParams":["get"], "selfRequestsOnly": false}'>
|
||||
```
|
||||
|
||||
IE is no longer supported in htmx 2.0, but htmx 1.x continues to support IE and will be supported for the foreseeable
|
||||
future.
|
||||
|
||||
## AJAX
|
||||
|
||||
The core of htmx is a set of attributes that allow you to issue AJAX requests directly from HTML:
|
||||
|
Loading…
x
Reference in New Issue
Block a user