mirror of
https://github.com/bigskysoftware/htmx.git
synced 2025-09-29 22:11:22 +00:00
Merge branch 'pull/388' into dev
This commit is contained in:
commit
e0decc9a19
@ -925,7 +925,7 @@ return (function () {
|
||||
function shouldCancel(elt) {
|
||||
return elt.tagName === "FORM" ||
|
||||
(matches(elt, 'input[type="submit"], button') && closest(elt, 'form') !== null) ||
|
||||
(elt.tagName === "A" && elt.href && elt.href.indexOf('#') !== 0);
|
||||
(elt.tagName === "A" && elt.href && elt.getAttribute('href').indexOf('#') !== 0);
|
||||
}
|
||||
|
||||
function ignoreBoostedAnchorCtrlClick(elt, evt) {
|
||||
|
@ -41,4 +41,24 @@ describe("Core htmx internals Tests", function() {
|
||||
chai.expect(htmx._("tokenizeString")("aa.aa")).to.be.deep.equal(['aa', '.', 'aa']);
|
||||
})
|
||||
|
||||
it("tags respond correctly to shouldCancel", function() {
|
||||
var anchorThatShouldCancel = make("<a href='/foo'></a>");
|
||||
htmx._("shouldCancel")(anchorThatShouldCancel).should.equal(true);
|
||||
|
||||
var anchorThatShouldNotCancel = make("<a href='#'></a>");
|
||||
htmx._("shouldCancel")(anchorThatShouldNotCancel).should.equal(false);
|
||||
|
||||
var form = make("<form></form>");
|
||||
htmx._("shouldCancel")(form).should.equal(true);
|
||||
|
||||
var form = make("<form><input id='i1' type='submit'></form>");
|
||||
var input = byId("i1");
|
||||
htmx._("shouldCancel")(input).should.equal(true);
|
||||
|
||||
var form = make("<form><button id='b1' type='submit'></form>");
|
||||
var button = byId("b1");
|
||||
htmx._("shouldCancel")(button).should.equal(true);
|
||||
|
||||
})
|
||||
|
||||
});
|
Loading…
x
Reference in New Issue
Block a user