diff --git a/src/htmx.js b/src/htmx.js index e94d4643..5489aebe 100644 --- a/src/htmx.js +++ b/src/htmx.js @@ -41,6 +41,7 @@ return (function () { requestClass:'htmx-request', settlingClass:'htmx-settling', swappingClass:'htmx-swapping', + attributesToSwizzle:["class", "style", "width", "height"] }, parseInterval:parseInterval, _:internalEval, @@ -380,8 +381,13 @@ return (function () { } function shouldSwizzleAttribute(name) { - return !(name === "id" || name === "value" || name.indexOf("@") >= 0); - + var attributesToSwizzle = htmx.config.attributesToSwizzle; + for (var i = 0; i < attributesToSwizzle.length; i++) { + if (name === attributesToSwizzle[i]) { + return true; + } + } + return false; } function cloneAttributes(mergeTo, mergeFrom) { @@ -392,12 +398,7 @@ return (function () { }); forEach(mergeFrom.attributes, function (attr) { if (shouldSwizzleAttribute(attr.name)) { - try { - mergeTo.setAttribute(attr.name, attr.value); - } catch (e) { - // log bad attributes, should be added to the shouldSwizzleAttribute function when reported - logError("Could not set attribute with name '" + attr.name + "'"); - } + mergeTo.setAttribute(attr.name, attr.value); } }); } diff --git a/test/core/ajax.js b/test/core/ajax.js index 715ad50f..0f570a86 100644 --- a/test/core/ajax.js +++ b/test/core/ajax.js @@ -353,13 +353,13 @@ describe("Core htmx AJAX Tests", function(){ it('properly settles attributes on interior elements', function(done) { - this.server.respondWith("GET", "/test", "
"); + this.server.respondWith("GET", "/test", "
"); var div = make("
"); div.click(); this.server.respond(); - should.equal(byId("d1").getAttribute("foo"), null); + should.equal(byId("d1").getAttribute("width"), null); setTimeout(function () { - should.equal(byId("d1").getAttribute("foo"), "bar"); + should.equal(byId("d1").getAttribute("width"), "bar"); done(); }, 20); });