mirror of
https://github.com/bigskysoftware/htmx.git
synced 2025-09-26 20:40:41 +00:00
prep 2.0.6 release
This commit is contained in:
parent
8e489ef6ee
commit
fe7f103eab
@ -1,5 +1,10 @@
|
||||
# Changelog
|
||||
|
||||
## [2.0.6] - 2025-06-27
|
||||
|
||||
* [Fix](https://github.com/bigskysoftware/htmx/pull/3357) a [regression](https://github.com/bigskysoftware/htmx/issues/3356)
|
||||
with htmx-powered links that contain other elements in them issuing full page refreshes
|
||||
|
||||
## [2.0.5] - 2025-06-20
|
||||
|
||||
* 100% test coverage! (Thank you @MichaelWest22!)
|
||||
|
@ -32,7 +32,7 @@ By removing these arbitrary constraints htmx completes HTML as a
|
||||
## quick start
|
||||
|
||||
```html
|
||||
<script src="https://cdn.jsdelivr.net/npm/htmx.org@2.0.5/dist/htmx.min.js"></script>
|
||||
<script src="https://cdn.jsdelivr.net/npm/htmx.org@2.0.6/dist/htmx.min.js"></script>
|
||||
<!-- have a button POST a click via AJAX -->
|
||||
<button hx-post="/clicked" hx-swap="outerHTML">
|
||||
Click Me
|
||||
|
4
dist/htmx.amd.js
vendored
4
dist/htmx.amd.js
vendored
@ -2436,7 +2436,9 @@ var htmx = (function() {
|
||||
if (elt.form && elt.type === 'submit') {
|
||||
return true
|
||||
}
|
||||
if (elt instanceof HTMLAnchorElement && elt.href &&
|
||||
elt = elt.closest('a')
|
||||
// @ts-ignore check for a link wrapping the event elt or if elt is a link. elt will be link so href check is fine
|
||||
if (elt && elt.href &&
|
||||
(elt.getAttribute('href') === '#' || elt.getAttribute('href').indexOf('#') !== 0)) {
|
||||
return true
|
||||
}
|
||||
|
4
dist/htmx.cjs.js
vendored
4
dist/htmx.cjs.js
vendored
@ -2435,7 +2435,9 @@ var htmx = (function() {
|
||||
if (elt.form && elt.type === 'submit') {
|
||||
return true
|
||||
}
|
||||
if (elt instanceof HTMLAnchorElement && elt.href &&
|
||||
elt = elt.closest('a')
|
||||
// @ts-ignore check for a link wrapping the event elt or if elt is a link. elt will be link so href check is fine
|
||||
if (elt && elt.href &&
|
||||
(elt.getAttribute('href') === '#' || elt.getAttribute('href').indexOf('#') !== 0)) {
|
||||
return true
|
||||
}
|
||||
|
4
dist/htmx.esm.js
vendored
4
dist/htmx.esm.js
vendored
@ -2435,7 +2435,9 @@ var htmx = (function() {
|
||||
if (elt.form && elt.type === 'submit') {
|
||||
return true
|
||||
}
|
||||
if (elt instanceof HTMLAnchorElement && elt.href &&
|
||||
elt = elt.closest('a')
|
||||
// @ts-ignore check for a link wrapping the event elt or if elt is a link. elt will be link so href check is fine
|
||||
if (elt && elt.href &&
|
||||
(elt.getAttribute('href') === '#' || elt.getAttribute('href').indexOf('#') !== 0)) {
|
||||
return true
|
||||
}
|
||||
|
4
dist/htmx.js
vendored
4
dist/htmx.js
vendored
@ -2435,7 +2435,9 @@ var htmx = (function() {
|
||||
if (elt.form && elt.type === 'submit') {
|
||||
return true
|
||||
}
|
||||
if (elt instanceof HTMLAnchorElement && elt.href &&
|
||||
elt = elt.closest('a')
|
||||
// @ts-ignore check for a link wrapping the event elt or if elt is a link. elt will be link so href check is fine
|
||||
if (elt && elt.href &&
|
||||
(elt.getAttribute('href') === '#' || elt.getAttribute('href').indexOf('#') !== 0)) {
|
||||
return true
|
||||
}
|
||||
|
2
dist/htmx.min.js
vendored
2
dist/htmx.min.js
vendored
File diff suppressed because one or more lines are too long
BIN
dist/htmx.min.js.gz
vendored
BIN
dist/htmx.min.js.gz
vendored
Binary file not shown.
@ -1,7 +1,7 @@
|
||||
{
|
||||
"$schema": "https://json.schemastore.org/web-types",
|
||||
"name": "htmx",
|
||||
"version": "2.0.5",
|
||||
"version": "2.0.6",
|
||||
"default-icon": "./htmx.svg",
|
||||
"js-types-syntax": "typescript",
|
||||
"description-markup": "markdown",
|
||||
|
@ -5,7 +5,7 @@
|
||||
"AJAX",
|
||||
"HTML"
|
||||
],
|
||||
"version": "2.0.5",
|
||||
"version": "2.0.6",
|
||||
"homepage": "https://htmx.org/",
|
||||
"bugs": {
|
||||
"url": "https://github.com/bigskysoftware/htmx/issues"
|
||||
|
@ -120,7 +120,7 @@ By removing these constraints, htmx completes HTML as a [hypertext](https://en.w
|
||||
<h2>quick start</h2>
|
||||
|
||||
```html
|
||||
<script src="https://cdn.jsdelivr.net/npm/htmx.org@2.0.5/dist/htmx.min.js"></script>
|
||||
<script src="https://cdn.jsdelivr.net/npm/htmx.org@2.0.6/dist/htmx.min.js"></script>
|
||||
<!-- have a button POST a click via AJAX -->
|
||||
<button hx-post="/clicked" hx-swap="outerHTML">
|
||||
Click Me
|
||||
|
@ -123,13 +123,13 @@ The fastest way to get going with htmx is to load it via a CDN. You can simply a
|
||||
your head tag and get going:
|
||||
|
||||
```html
|
||||
<script src="https://cdn.jsdelivr.net/npm/htmx.org@2.0.5/dist/htmx.min.js" integrity="sha384-t4DxZSyQK+0Uv4jzy5B0QyHyWQD2GFURUmxKMBVww9+e2EJ0ei/vCvv7+79z0fkr" crossorigin="anonymous"></script>
|
||||
<script src="https://cdn.jsdelivr.net/npm/htmx.org@2.0.6/dist/htmx.min.js" integrity="sha384-letifTFBDHi9rx8nQYggBy3ptAIO+3NkVsN2Ab/4N3SMF/PhyI/bJ7aCJyQGF0MS" crossorigin="anonymous"></script>
|
||||
```
|
||||
|
||||
An unminified version is also available as well:
|
||||
|
||||
```html
|
||||
<script src="https://cdn.jsdelivr.net/npm/htmx.org@2.0.5/dist/htmx.js" integrity="sha384-5DNWP7/6VfmFjDrEgZ0MwJiuIz0/juUdZwgMAqxCaHBd/BH8MF4yWxDv+mo/o9CG" crossorigin="anonymous"></script>
|
||||
<script src="https://cdn.jsdelivr.net/npm/htmx.org@2.0.6/dist/htmx.js" integrity="sha384-2DEvJAJIghIiKR92v4VHOyst762QNva3S6lAZo/aOCh4d7HGL7Mk+4x9LPcfA/Qn" crossorigin="anonymous"></script>
|
||||
```
|
||||
|
||||
While the CDN approach is extremely simple, you may want to consider
|
||||
@ -139,7 +139,7 @@ While the CDN approach is extremely simple, you may want to consider
|
||||
|
||||
The next easiest way to install htmx is to simply copy it into your project.
|
||||
|
||||
Download `htmx.min.js` [from jsDelivr](https://cdn.jsdelivr.net/npm/htmx.org@2.0.5/dist/htmx.min.js) and add it to the appropriate directory in your project
|
||||
Download `htmx.min.js` [from jsDelivr](https://cdn.jsdelivr.net/npm/htmx.org@2.0.6/dist/htmx.min.js) and add it to the appropriate directory in your project
|
||||
and include it where necessary with a `<script>` tag:
|
||||
|
||||
```html
|
||||
@ -151,7 +151,7 @@ and include it where necessary with a `<script>` tag:
|
||||
For npm-style build systems, you can install htmx via [npm](https://www.npmjs.com/):
|
||||
|
||||
```sh
|
||||
npm install htmx.org@2.0.5
|
||||
npm install htmx.org@2.0.6
|
||||
```
|
||||
|
||||
After installing, you’ll need to use appropriate tooling to use `node_modules/htmx.org/dist/htmx.js` (or `.min.js`).
|
||||
@ -1140,7 +1140,7 @@ You can see all available extensions on the [Extensions](/extensions) page.
|
||||
The fastest way to install htmx extensions created by others is to load them via a CDN. Remember to always include the core htmx library before the extensions and [enable the extension](#enabling-extensions). For example, if you would like to use the [response-targets](/extensions/response-targets) extension, you can add this to your head tag:
|
||||
```HTML
|
||||
<head>
|
||||
<script src="https://cdn.jsdelivr.net/npm/htmx.org@2.0.5/dist/htmx.min.js" integrity="sha384-t4DxZSyQK+0Uv4jzy5B0QyHyWQD2GFURUmxKMBVww9+e2EJ0ei/vCvv7+79z0fkr" crossorigin="anonymous"></script>
|
||||
<script src="https://cdn.jsdelivr.net/npm/htmx.org@2.0.6/dist/htmx.min.js" integrity="sha384-letifTFBDHi9rx8nQYggBy3ptAIO+3NkVsN2Ab/4N3SMF/PhyI/bJ7aCJyQGF0MS" crossorigin="anonymous"></script>
|
||||
<script src="https://cdn.jsdelivr.net/npm/htmx-ext-response-targets@2.0.2" integrity="sha384-UMuM7P2CPg9i2/dfvBlAeqjXITmEWe9k17Mp9X07Z4jXPN21Ychng569t+sUL8oa" crossorigin="anonymous"></script>
|
||||
</head>
|
||||
<body hx-ext="extension-name">
|
||||
|
@ -18,7 +18,7 @@ a feature of the library. This extension addresses that shortcoming.
|
||||
The fastest way to install `head-support` is to load it via a CDN. Remember to always include the core htmx library before the extension and [enable the extension](#usage).
|
||||
```HTML
|
||||
<head>
|
||||
<script src="https://cdn.jsdelivr.net/npm/htmx.org@2.0.5/dist/htmx.min.js" integrity="sha384-HGfztofotfshcF7+8n44JQL2oJmowVChPTg48S+jvZoztPfvwD79OC/LTtG6dMp+" crossorigin="anonymous"></script>
|
||||
<script src="https://cdn.jsdelivr.net/npm/htmx.org@2.0.6/dist/htmx.min.js" integrity="sha384-HGfztofotfshcF7+8n44JQL2oJmowVChPTg48S+jvZoztPfvwD79OC/LTtG6dMp+" crossorigin="anonymous"></script>
|
||||
<script src="https://cdn.jsdelivr.net/npm/htmx-ext-head-support@2.0.2" integrity="sha384-cvMqHzjCJsOHgGuyB3sWXaUSv/Krm0BdzjuI1rtkjCbL1l1oHJx+cHyVRJhyuEz0" crossorigin="anonymous"></script>
|
||||
</head>
|
||||
<body hx-ext="head-support">
|
||||
|
@ -9,7 +9,7 @@ The `htmx-1-compat` extension allows you to almost seamlessly upgrade from htmx
|
||||
The fastest way to install `htmx-1-compat` is to load it via a CDN. Remember to always include the core htmx library before the extension and enable the extension.
|
||||
```HTML
|
||||
<head>
|
||||
<script src="https://cdn.jsdelivr.net/npm/htmx.org@2.0.5/dist/htmx.min.js" integrity="sha384-HGfztofotfshcF7+8n44JQL2oJmowVChPTg48S+jvZoztPfvwD79OC/LTtG6dMp+" crossorigin="anonymous"></script>
|
||||
<script src="https://cdn.jsdelivr.net/npm/htmx.org@2.0.6/dist/htmx.min.js" integrity="sha384-HGfztofotfshcF7+8n44JQL2oJmowVChPTg48S+jvZoztPfvwD79OC/LTtG6dMp+" crossorigin="anonymous"></script>
|
||||
<script src="https://cdn.jsdelivr.net/npm/htmx-ext-htmx-1-compat@2.0.0" integrity="sha384-lcvVWaNjF5zPPUeeWmC0OkJ2MLqoWLlkAabuGm+EuMSTfGo5WRyHrNaAp0cJr9Pg" crossorigin="anonymous"></script>
|
||||
</head>
|
||||
<body hx-ext="htmx-1-compat">
|
||||
|
@ -15,7 +15,7 @@ extension.
|
||||
The fastest way to install `idiomorph` is to load it via a CDN. Remember to always include the core htmx library before the extension and [enable the extension](#usage).
|
||||
```HTML
|
||||
<head>
|
||||
<script src="https://cdn.jsdelivr.net/npm/htmx.org@2.0.5/dist/htmx.min.js@2.0.5" integrity="sha384-HGfztofotfshcF7+8n44JQL2oJmowVChPTg48S+jvZoztPfvwD79OC/LTtG6dMp+" crossorigin="anonymous"></script>
|
||||
<script src="https://cdn.jsdelivr.net/npm/htmx.org@2.0.6/dist/htmx.min.js@2.0.6" integrity="sha384-HGfztofotfshcF7+8n44JQL2oJmowVChPTg48S+jvZoztPfvwD79OC/LTtG6dMp+" crossorigin="anonymous"></script>
|
||||
<script src="https://unpkg.com/idiomorph@0.7.3" integrity="sha384-JcorokHTL/m+D6ZHe2+yFVQopVwZ+91GxAPDyEZ6/A/OEPGEx1+MeNSe2OGvoRS9" crossorigin="anonymous"></script>
|
||||
<script src="https://unpkg.com/idiomorph@0.7.3/dist/idiomorph-ext.min.js" integrity="sha384-szktAZju9fwY15dZ6D2FKFN4eZoltuXiHStNDJWK9+FARrxJtquql828JzikODob" crossorigin="anonymous"></script>
|
||||
</head>
|
||||
|
@ -15,7 +15,7 @@ unused requests. Use this extension carefully!
|
||||
The fastest way to install `preload` is to load it via a CDN. Remember to always include the core htmx library before the extension and [enable the extension](#usage).
|
||||
```HTML
|
||||
<head>
|
||||
<script src="https://cdn.jsdelivr.net/npm/htmx.org@2.0.5/dist/htmx.min.js" integrity="sha384-HGfztofotfshcF7+8n44JQL2oJmowVChPTg48S+jvZoztPfvwD79OC/LTtG6dMp+" crossorigin="anonymous"></script>
|
||||
<script src="https://cdn.jsdelivr.net/npm/htmx.org@2.0.6/dist/htmx.min.js" integrity="sha384-HGfztofotfshcF7+8n44JQL2oJmowVChPTg48S+jvZoztPfvwD79OC/LTtG6dMp+" crossorigin="anonymous"></script>
|
||||
<script src="https://cdn.jsdelivr.net/npm/htmx-ext-preload@2.1.0" integrity="sha384-fkzubQiTB69M7XTToqW6tplvxAOJkqPl5JmLAbumV2EacmuJb8xEP9KnJafk/rg8" crossorigin="anonymous"></script>
|
||||
</head>
|
||||
<body hx-ext="preload">
|
||||
|
@ -27,7 +27,7 @@ The value of each attribute can be:
|
||||
The fastest way to install `response-targets` is to load it via a CDN. Remember to always include the core htmx library before the extension and [enable the extension](#usage).
|
||||
```HTML
|
||||
<head>
|
||||
<script src="https://cdn.jsdelivr.net/npm/htmx.org@2.0.5/dist/htmx.min.js" integrity="sha384-HGfztofotfshcF7+8n44JQL2oJmowVChPTg48S+jvZoztPfvwD79OC/LTtG6dMp+" crossorigin="anonymous"></script>
|
||||
<script src="https://cdn.jsdelivr.net/npm/htmx.org@2.0.6/dist/htmx.min.js" integrity="sha384-HGfztofotfshcF7+8n44JQL2oJmowVChPTg48S+jvZoztPfvwD79OC/LTtG6dMp+" crossorigin="anonymous"></script>
|
||||
<script src="https://cdn.jsdelivr.net/npm/htmx-ext-response-targets@2.0.2" integrity="sha384-T41oglUPvXLGBVyRdZsVRxNWnOOqCynaPubjUVjxhsjFTKrFJGEMm3/0KGmNQ+Pg" crossorigin="anonymous"></script>
|
||||
</head>
|
||||
<body hx-ext="response-targets">
|
||||
|
@ -29,7 +29,7 @@ Use the following attributes to configure how SSE connections behave:
|
||||
The fastest way to install `sse` is to load it via a CDN. Remember to always include the core htmx library before the extension and [enable the extension](#usage).
|
||||
```HTML
|
||||
<head>
|
||||
<script src="https://cdn.jsdelivr.net/npm/htmx.org@2.0.5/dist/htmx.min.js" integrity="sha384-HGfztofotfshcF7+8n44JQL2oJmowVChPTg48S+jvZoztPfvwD79OC/LTtG6dMp+" crossorigin="anonymous"></script>
|
||||
<script src="https://cdn.jsdelivr.net/npm/htmx.org@2.0.6/dist/htmx.min.js" integrity="sha384-HGfztofotfshcF7+8n44JQL2oJmowVChPTg48S+jvZoztPfvwD79OC/LTtG6dMp+" crossorigin="anonymous"></script>
|
||||
<script src="https://cdn.jsdelivr.net/npm/htmx-ext-sse@2.2.2" integrity="sha384-Y4gc0CK6Kg+hmulDc6rZPJu0tqvk7EWlih0Oh+2OkAi1ZDlCbBDCQEE2uVk472Ky" crossorigin="anonymous"></script>
|
||||
</head>
|
||||
<body hx-ext="sse">
|
||||
|
@ -23,7 +23,7 @@ Use the following attributes to configure how WebSockets behave:
|
||||
The fastest way to install `ws` is to load it via a CDN. Remember to always include the core htmx library before the extension and [enable the extension](#usage).
|
||||
```HTML
|
||||
<head>
|
||||
<script src="https://cdn.jsdelivr.net/npm/htmx.org@2.0.5/dist/htmx.min.js" integrity="sha384-HGfztofotfshcF7+8n44JQL2oJmowVChPTg48S+jvZoztPfvwD79OC/LTtG6dMp+" crossorigin="anonymous"></script>
|
||||
<script src="https://cdn.jsdelivr.net/npm/htmx.org@2.0.6/dist/htmx.min.js" integrity="sha384-HGfztofotfshcF7+8n44JQL2oJmowVChPTg48S+jvZoztPfvwD79OC/LTtG6dMp+" crossorigin="anonymous"></script>
|
||||
<script src="https://cdn.jsdelivr.net/npm/htmx-ext-ws@2.0.2" integrity="sha384-vuKxTKv5TX/b3lLzDKP2U363sOAoRo5wSvzzc3LJsbaQRSBSS+3rKKHcOx5J8doU" crossorigin="anonymous"></script>
|
||||
</head>
|
||||
<body hx-ext="ws">
|
||||
|
@ -2435,7 +2435,9 @@ var htmx = (function() {
|
||||
if (elt.form && elt.type === 'submit') {
|
||||
return true
|
||||
}
|
||||
if (elt instanceof HTMLAnchorElement && elt.href &&
|
||||
elt = elt.closest('a')
|
||||
// @ts-ignore check for a link wrapping the event elt or if elt is a link. elt will be link so href check is fine
|
||||
if (elt && elt.href &&
|
||||
(elt.getAttribute('href') === '#' || elt.getAttribute('href').indexOf('#') !== 0)) {
|
||||
return true
|
||||
}
|
||||
|
@ -107,6 +107,11 @@ describe('Core htmx internals Tests', function() {
|
||||
htmx._('shouldCancel')({ type: 'submit', target: anchorThatShouldNotCancel }, form).should.equal(false)
|
||||
htmx._('shouldCancel')({ type: 'click', target: divThatShouldNotCancel }, form).should.equal(false)
|
||||
|
||||
// check elements inside links getting click events should cancel parent links
|
||||
var anchorWithButton = make("<a href='/foo'><button></button></a>")
|
||||
htmx._('shouldCancel')({ type: 'click', target: anchorWithButton.firstChild }, anchorWithButton).should.equal(true)
|
||||
htmx._('shouldCancel')({ type: 'click', target: anchorWithButton.firstChild }, anchorWithButton.firstChild).should.equal(true)
|
||||
|
||||
form = make('<form id="f1">' +
|
||||
'<input id="insideInput" type="submit">' +
|
||||
'<button id="insideFormBtn"></button>' +
|
||||
|
@ -291,4 +291,46 @@ describe('Core htmx Regression Tests', function() {
|
||||
|
||||
byId('datefield').click()
|
||||
})
|
||||
|
||||
it('a button clicked inside an htmx enabled link will prevent the link from navigating on click', function(done) {
|
||||
var defaultPrevented = 'unset'
|
||||
var link = make('<a href="/foo" hx-get="/foo"><button>test</button></a>')
|
||||
var button = link.firstChild
|
||||
|
||||
htmx.on(link, 'click', function(evt) {
|
||||
// we need to wait so the state of the evt is finalized
|
||||
setTimeout(() => {
|
||||
defaultPrevented = evt.defaultPrevented
|
||||
try {
|
||||
defaultPrevented.should.equal(true)
|
||||
done()
|
||||
} catch (err) {
|
||||
done(err)
|
||||
}
|
||||
}, 0)
|
||||
})
|
||||
|
||||
button.click()
|
||||
})
|
||||
|
||||
it('a htmx enabled button clicked inside a link will prevent the link from navigating on click', function(done) {
|
||||
var defaultPrevented = 'unset'
|
||||
var link = make('<a href="/foo"><button hx-get="/foo">test</button></a>')
|
||||
var button = link.firstChild
|
||||
|
||||
htmx.on(link, 'click', function(evt) {
|
||||
// we need to wait so the state of the evt is finalized
|
||||
setTimeout(() => {
|
||||
defaultPrevented = evt.defaultPrevented
|
||||
try {
|
||||
defaultPrevented.should.equal(true)
|
||||
done()
|
||||
} catch (err) {
|
||||
done(err)
|
||||
}
|
||||
}, 0)
|
||||
})
|
||||
|
||||
button.click()
|
||||
})
|
||||
})
|
||||
|
@ -2435,7 +2435,9 @@ var htmx = (function() {
|
||||
if (elt.form && elt.type === 'submit') {
|
||||
return true
|
||||
}
|
||||
if (elt instanceof HTMLAnchorElement && elt.href &&
|
||||
elt = elt.closest('a')
|
||||
// @ts-ignore check for a link wrapping the event elt or if elt is a link. elt will be link so href check is fine
|
||||
if (elt && elt.href &&
|
||||
(elt.getAttribute('href') === '#' || elt.getAttribute('href').indexOf('#') !== 0)) {
|
||||
return true
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user