From 276082f2c23c171b86b86213e2c74a829a28cb3b Mon Sep 17 00:00:00 2001 From: carson Date: Fri, 19 Jun 2020 06:29:46 -0700 Subject: [PATCH] exclude value and id from the settle swap to avoid flicker --- src/htmx.js | 7 +++++-- test/core/ajax.js | 12 ++++++++++++ 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/src/htmx.js b/src/htmx.js index 3c0453d2..13c84fd8 100644 --- a/src/htmx.js +++ b/src/htmx.js @@ -334,14 +334,17 @@ return (function () { } } + var EXCLUDED_ATTRIBUTES = ['id', 'value']; function cloneAttributes(mergeTo, mergeFrom) { 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) } }); forEach(mergeFrom.attributes, function (attr) { - mergeTo.setAttribute(attr.name, attr.value); + if (EXCLUDED_ATTRIBUTES.indexOf(attr.name) === -1) { + mergeTo.setAttribute(attr.name, attr.value); + } }); } diff --git a/test/core/ajax.js b/test/core/ajax.js index 750067f3..8d51dc56 100644 --- a/test/core/ajax.js +++ b/test/core/ajax.js @@ -444,6 +444,7 @@ describe("Core htmx AJAX Tests", function(){ return false; }); div.click(); + this.server.respond(); path.should.not.be.null; }); @@ -456,8 +457,19 @@ describe("Core htmx AJAX Tests", function(){ return false; }); div.click(); + this.server.respond(); path.should.not.be.null; }); + it('input values are not settle swapped (causes flicker)', function() + { + this.server.respondWith("GET", "/test", ""); + var input = make(""); + input.click(); + this.server.respond(); + input = byId('i1'); + input.value.should.equal('bar'); + }); + })