search for extensions in new content

fixes https://github.com/bigskysoftware/htmx/issues/281
This commit is contained in:
carson 2021-11-12 15:37:29 -07:00
parent 8f15965797
commit 2944bf372c
4 changed files with 16 additions and 3 deletions

View File

@ -5,6 +5,9 @@
var _root = this;
function dependsOn(pathSpec, url) {
if (pathSpec === "ignore") {
return false;
}
var dependencyPath = pathSpec.split("/");
var urlPath = url.split("/");
for (var i = 0; i < urlPath.length; i++) {
@ -35,7 +38,7 @@
if (name === "htmx:beforeOnLoad") {
var config = evt.detail.requestConfig;
// mutating call
if (config.verb !== "get") {
if (config.verb !== "get" && evt.target.getAttribute('path-deps') !== 'ignore') {
refreshPath(config.path);
}
}

View File

@ -15,7 +15,7 @@
if (elt.getAttribute) {
maybeRemoveMe(elt);
if (elt.querySelectorAll) {
var children = elt.querySelectorAll("[remove-me], [data-remove-me");
var children = elt.querySelectorAll("[remove-me], [data-remove-me]");
for (var i = 0; i < children.length; i++) {
maybeRemoveMe(children[i]);
}

View File

@ -1444,7 +1444,7 @@ return (function () {
if (elt.querySelectorAll) {
var boostedElts = isBoosted() ? ", a, form" : "";
var results = elt.querySelectorAll(VERB_SELECTOR + boostedElts + ", [hx-sse], [data-hx-sse], [hx-ws]," +
" [data-hx-ws]");
" [data-hx-ws], [hx-ext], [hx-data-ext]");
return results;
} else {
return [];

View File

@ -39,5 +39,15 @@ describe("remove-me extension", function(){
}, 100);
});
it('extension can be on a child', function(done)
{
var div = make('<div><div hx-ext="remove-me" id="d1" remove-me="20ms">Click Me!</div></div>')
should.equal(div.classList.length, 0);
setTimeout(function(){
should.equal(byId("d1"), null);
done();
}, 100);
});
})