summaryrefslogtreecommitdiffstatshomepage
path: root/test/attributes/hx-trigger.js
diff options
context:
space:
mode:
Diffstat (limited to 'test/attributes/hx-trigger.js')
-rw-r--r--test/attributes/hx-trigger.js59
1 files changed, 59 insertions, 0 deletions
diff --git a/test/attributes/hx-trigger.js b/test/attributes/hx-trigger.js
index 5e2f138b..0cbb4adf 100644
--- a/test/attributes/hx-trigger.js
+++ b/test/attributes/hx-trigger.js
@@ -895,5 +895,64 @@ describe("hx-trigger attribute", function(){
form.innerHTML.should.equal("Called!");
})
+ it("correctly handles CSS descendant combinators", function(){
+ this.server.respondWith("GET", "/test", "Clicked!");
+
+ var outer = make(`
+ <div>
+ <div id='outer'>
+ <div id='first'>
+ <div id='inner'></div>
+ </div>
+ <div id='second' hx-get='/test' hx-trigger='click from:previous (#outer div)'>Unclicked.</div>
+ </div>
+ <div id='other' hx-get='/test' hx-trigger='click from:(div #inner)'>Unclicked.</div>
+ </div>
+ `);
+
+ var inner = byId("inner");
+ var second = byId("second");
+ var other = byId("other");
+
+ second.innerHTML.should.equal("Unclicked.");
+ other.innerHTML.should.equal("Unclicked.");
+
+ inner.click();
+ this.server.respond();
+
+ second.innerHTML.should.equal("Clicked!");
+ other.innerHTML.should.equal("Clicked!");
+ })
+
+
+ it('correctly handles CSS descendant combinators in modifier target', function() {
+ this.server.respondWith('GET', '/test', 'Called');
+
+ document.addEventListener('htmx:syntax:error', function(evt) {
+ chai.assert.fail('htmx:syntax:error');
+ });
+
+ make('<div class="d1"><a id="a1" class="a1">Click me</a><a id="a2" class="a2">Click me</a></div>');
+ var div = make('<div hx-trigger="click from:body target:(.d1 .a2)" hx-get="/test">Not Called</div>');
+
+ byId('a1').click();
+ this.server.respond();
+ div.innerHTML.should.equal("Not Called");
+
+ byId('a2').click();
+ this.server.respond();
+ div.innerHTML.should.equal("Called");
+ });
+
+ it('correctly handles CSS descendant combinators in modifier root', function() {
+ this.server.respondWith('GET', '/test', 'Called');
+
+ document.addEventListener('htmx:syntax:error', function(evt) {
+ chai.assert.fail('htmx:syntax:error');
+ });
+
+ make('<div hx-trigger="intersect root:{form input}" hx-get="/test">Not Called</div>');
+ });
+
})