summaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
authorCarson Gross <carson@bigsky.software>2023-11-21 14:57:52 -0700
committerCarson Gross <carson@bigsky.software>2023-11-21 14:57:52 -0700
commit5c42b3442bf98bd2abdf9accefa0a86292db5b39 (patch)
tree9a759247f481417915ba2cab3f645f8d2ce4a420
parent555522baaad323a5160ed86ded33622ee246d257 (diff)
downloadhtmx-5c42b3442bf98bd2abdf9accefa0a86292db5b39.tar.gz
htmx-5c42b3442bf98bd2abdf9accefa0a86292db5b39.zip
flip defaults for 2.0
-rw-r--r--src/htmx.js6
-rw-r--r--test/core/events.js2
-rw-r--r--test/core/security.js6
-rw-r--r--www/content/docs.md22
4 files changed, 30 insertions, 6 deletions
diff --git a/src/htmx.js b/src/htmx.js
index 1f0709d7..94a052e1 100644
--- a/src/htmx.js
+++ b/src/htmx.js
@@ -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
},
diff --git a/test/core/events.js b/test/core/events.js
index 7c1c1596..c8c1b829 100644
--- a/test/core/events.js
+++ b/test/core/events.js
@@ -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);
});
diff --git a/test/core/security.js b/test/core/security.js
index 95f17350..733a4ef9 100644
--- a/test/core/security.js
+++ b/test/core/security.js
@@ -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();
})
diff --git a/www/content/docs.md b/www/content/docs.md
index 1f2dd0a6..8a3130d1 100644
--- a/www/content/docs.md
+++ b/www/content/docs.md
@@ -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: