mirror of
https://github.com/bigskysoftware/htmx.git
synced 2025-09-28 21:41:40 +00:00
support unset
to, well, unset attributes
This commit is contained in:
parent
7a858fab42
commit
e3cb9b591a
@ -128,7 +128,9 @@ return (function () {
|
||||
getClosestMatch(elt, function (e) {
|
||||
return closestAttr = getAttributeValue(e, attributeName);
|
||||
});
|
||||
return closestAttr;
|
||||
if (closestAttr !== "unset") {
|
||||
return closestAttr;
|
||||
}
|
||||
}
|
||||
|
||||
function matches(elt, selector) {
|
||||
|
@ -1,5 +1,14 @@
|
||||
describe("Core htmx internals Tests", function() {
|
||||
|
||||
beforeEach(function () {
|
||||
this.server = makeServer();
|
||||
clearWorkArea();
|
||||
});
|
||||
afterEach(function () {
|
||||
this.server.restore();
|
||||
clearWorkArea();
|
||||
});
|
||||
|
||||
it("makeFragment works with janky stuff", function(){
|
||||
htmx._("makeFragment")("<html></html>").tagName.should.equal("BODY");
|
||||
htmx._("makeFragment")("<html><body></body></html>").tagName.should.equal("BODY");
|
||||
@ -35,6 +44,7 @@ describe("Core htmx internals Tests", function() {
|
||||
}
|
||||
})
|
||||
|
||||
|
||||
it("makeFragment works with template wrapping and funky combos", function(){
|
||||
htmx.config.useTemplateFragments = true;
|
||||
try {
|
||||
@ -98,4 +108,22 @@ describe("Core htmx internals Tests", function() {
|
||||
|
||||
})
|
||||
|
||||
it("unset properly unsets a given attribute", function(){
|
||||
make("<div foo='1'><div foo='2'><div foo='unset' id='d1'></div></div></div>");
|
||||
var div = byId("d1");
|
||||
should.equal(undefined, htmx._("getClosestAttributeValue")(div, "foo"));
|
||||
})
|
||||
|
||||
it("unset properly unsets a given attribute on a parent", function(){
|
||||
make("<div foo='1'><div foo='unset'><div id='d1'></div></div></div>");
|
||||
var div = byId("d1");
|
||||
should.equal(undefined, htmx._("getClosestAttributeValue")(div, "foo"));
|
||||
})
|
||||
|
||||
it("unset does not unset a value below it in the hierarchy", function(){
|
||||
make("<div foo='unset'><div foo='2'><div id='d1'></div></div></div>");
|
||||
var div = byId("d1");
|
||||
should.equal("2", htmx._("getClosestAttributeValue")(div, "foo"));
|
||||
})
|
||||
|
||||
});
|
Loading…
x
Reference in New Issue
Block a user