mirror of
https://github.com/bigskysoftware/htmx.git
synced 2025-09-26 20:40:41 +00:00
bump verison + add this
symbol in filter expressions
This commit is contained in:
parent
b4efcbaa46
commit
c96f01e81e
@ -1,5 +1,7 @@
|
||||
# Changelog
|
||||
|
||||
## [1.9.3] - 2023-04-28
|
||||
|
||||
## [1.9.2] - 2023-04-28
|
||||
|
||||
* Fixed bug w/ `hx-on` not properly de-initializing
|
||||
|
@ -33,7 +33,7 @@ By removing these arbitrary constraints htmx completes HTML as a
|
||||
## quick start
|
||||
|
||||
```html
|
||||
<script src="https://unpkg.com/htmx.org@1.9.2"></script>
|
||||
<script src="https://unpkg.com/htmx.org@1.9.3"></script>
|
||||
<!-- have a button POST a click via AJAX -->
|
||||
<button hx-post="/clicked" hx-swap="outerHTML">
|
||||
Click Me
|
||||
|
@ -5,7 +5,7 @@
|
||||
"AJAX",
|
||||
"HTML"
|
||||
],
|
||||
"version": "1.9.2",
|
||||
"version": "1.9.3",
|
||||
"homepage": "https://htmx.org/",
|
||||
"bugs": {
|
||||
"url": "https://github.com/bigskysoftware/htmx/issues"
|
||||
|
15
src/htmx.js
15
src/htmx.js
@ -82,7 +82,7 @@ return (function () {
|
||||
sock.binaryType = htmx.config.wsBinaryType;
|
||||
return sock;
|
||||
},
|
||||
version: "1.9.2"
|
||||
version: "1.9.3"
|
||||
};
|
||||
|
||||
/** @type {import("./htmx").HtmxInternalApi} */
|
||||
@ -1299,7 +1299,10 @@ return (function () {
|
||||
var nodeData = getInternalData(elt);
|
||||
nodeData.timeout = setTimeout(function () {
|
||||
if (bodyContains(elt) && nodeData.cancelled !== true) {
|
||||
if (!maybeFilterEvent(spec, makeEvent('hx:poll:trigger', {triggerSpec:spec, target:elt}))) {
|
||||
if (!maybeFilterEvent(spec, elt, makeEvent('hx:poll:trigger', {
|
||||
triggerSpec: spec,
|
||||
target: elt
|
||||
}))) {
|
||||
handler(elt);
|
||||
}
|
||||
processPolling(elt, handler, spec);
|
||||
@ -1361,11 +1364,11 @@ return (function () {
|
||||
return getInternalData(elt).boosted && elt.tagName === "A" && evt.type === "click" && (evt.ctrlKey || evt.metaKey);
|
||||
}
|
||||
|
||||
function maybeFilterEvent(triggerSpec, evt) {
|
||||
function maybeFilterEvent(triggerSpec, elt, evt) {
|
||||
var eventFilter = triggerSpec.eventFilter;
|
||||
if(eventFilter){
|
||||
try {
|
||||
return eventFilter(evt) !== true;
|
||||
return eventFilter.call(elt, evt) !== true;
|
||||
} catch(e) {
|
||||
triggerErrorEvent(getDocument().body, "htmx:eventFilter:error", {error: e, source:eventFilter.source});
|
||||
return true;
|
||||
@ -1398,7 +1401,7 @@ return (function () {
|
||||
if (explicitCancel || shouldCancel(evt, elt)) {
|
||||
evt.preventDefault();
|
||||
}
|
||||
if (maybeFilterEvent(triggerSpec, evt)) {
|
||||
if (maybeFilterEvent(triggerSpec, elt, evt)) {
|
||||
return;
|
||||
}
|
||||
var eventData = getInternalData(evt);
|
||||
@ -1770,7 +1773,7 @@ return (function () {
|
||||
observer.observe(elt);
|
||||
addEventListener(elt, handler, nodeData, triggerSpec);
|
||||
} else if (triggerSpec.trigger === "load") {
|
||||
if (!maybeFilterEvent(triggerSpec, makeEvent("load", {elt:elt}))) {
|
||||
if (!maybeFilterEvent(triggerSpec, elt, makeEvent("load", {elt: elt}))) {
|
||||
loadImmediately(elt, handler, nodeData, triggerSpec.delay);
|
||||
}
|
||||
} else if (triggerSpec.pollInterval) {
|
||||
|
@ -784,4 +784,18 @@ describe("hx-trigger attribute", function(){
|
||||
}
|
||||
});
|
||||
|
||||
it('filters support "this" reference to the current element', function(){
|
||||
this.server.respondWith("GET", "/test", "Called!");
|
||||
var form = make('<form hx-get="/test" hx-trigger="click[this.classList.contains(\'bar\')]">Not Called</form>');
|
||||
form.click();
|
||||
this.server.respond();
|
||||
form.innerHTML.should.equal("Not Called");
|
||||
|
||||
form.classList.add('bar');
|
||||
form.click();
|
||||
this.server.respond();
|
||||
form.innerHTML.should.equal("Called!");
|
||||
})
|
||||
|
||||
|
||||
})
|
||||
|
@ -32,7 +32,7 @@ By removing these arbitrary constraints, htmx completes HTML as a [hypertext](ht
|
||||
<h2>quick start</h2>
|
||||
|
||||
```html
|
||||
<script src="https://unpkg.com/htmx.org@1.9.2"></script>
|
||||
<script src="https://unpkg.com/htmx.org@1.9.3"></script>
|
||||
<!-- have a button POST a click via AJAX -->
|
||||
<button hx-post="/clicked" hx-swap="outerHTML">
|
||||
Click Me
|
||||
|
@ -114,7 +114,7 @@ The fastest way to get going with htmx is to load it via a CDN. You can simply a
|
||||
and get going:
|
||||
|
||||
```html
|
||||
<script src="https://unpkg.com/htmx.org@1.9.2" integrity="sha384-L6OqL9pRWyyFU3+/bjdSri+iIphTN/bvYyM37tICVyOJkWZLpP2vGn6VUEXgzg6h" crossorigin="anonymous"></script>
|
||||
<script src="https://unpkg.com/htmx.org@1.9.3" integrity="sha384-TODO" crossorigin="anonymous"></script>
|
||||
```
|
||||
|
||||
While the CDN approach is extremely simple, you may want to consider [not using CDNs in production](https://blog.wesleyac.com/posts/why-not-javascript-cdn).
|
||||
@ -266,7 +266,8 @@ Here is an example that triggers only on a Control-Click of the element
|
||||
</div>
|
||||
```
|
||||
|
||||
Properties like `ctrlKey` will be resolved against the triggering event first, then the global scope.
|
||||
Properties like `ctrlKey` will be resolved against the triggering event first, then the global scope. The
|
||||
`this` symbol will be set to the current element.
|
||||
|
||||
#### Special Events
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user