mirror of
https://github.com/bigskysoftware/htmx.git
synced 2025-10-02 15:25:26 +00:00
exclude value and id from the settle swap to avoid flicker
This commit is contained in:
parent
2524fcf436
commit
276082f2c2
@ -334,14 +334,17 @@ return (function () {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var EXCLUDED_ATTRIBUTES = ['id', 'value'];
|
||||||
function cloneAttributes(mergeTo, mergeFrom) {
|
function cloneAttributes(mergeTo, mergeFrom) {
|
||||||
forEach(mergeTo.attributes, function (attr) {
|
forEach(mergeTo.attributes, function (attr) {
|
||||||
if (!mergeFrom.hasAttribute(attr.name)) {
|
if (!mergeFrom.hasAttribute(attr.name) && EXCLUDED_ATTRIBUTES.indexOf(attr.name) === -1) {
|
||||||
mergeTo.removeAttribute(attr.name)
|
mergeTo.removeAttribute(attr.name)
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
forEach(mergeFrom.attributes, function (attr) {
|
forEach(mergeFrom.attributes, function (attr) {
|
||||||
mergeTo.setAttribute(attr.name, attr.value);
|
if (EXCLUDED_ATTRIBUTES.indexOf(attr.name) === -1) {
|
||||||
|
mergeTo.setAttribute(attr.name, attr.value);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -444,6 +444,7 @@ describe("Core htmx AJAX Tests", function(){
|
|||||||
return false;
|
return false;
|
||||||
});
|
});
|
||||||
div.click();
|
div.click();
|
||||||
|
this.server.respond();
|
||||||
path.should.not.be.null;
|
path.should.not.be.null;
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -456,8 +457,19 @@ describe("Core htmx AJAX Tests", function(){
|
|||||||
return false;
|
return false;
|
||||||
});
|
});
|
||||||
div.click();
|
div.click();
|
||||||
|
this.server.respond();
|
||||||
path.should.not.be.null;
|
path.should.not.be.null;
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('input values are not settle swapped (causes flicker)', function()
|
||||||
|
{
|
||||||
|
this.server.respondWith("GET", "/test", "<input id='i1' value='bar'/>");
|
||||||
|
var input = make("<input id='i1' hx-get='/test' value='foo' hx-swap='outerHTML settle:50' hx-trigger='click'/>");
|
||||||
|
input.click();
|
||||||
|
this.server.respond();
|
||||||
|
input = byId('i1');
|
||||||
|
input.value.should.equal('bar');
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
})
|
})
|
||||||
|
Loading…
x
Reference in New Issue
Block a user