From f3953e32149bdcaff479c9f66a0185f6b9292dfb Mon Sep 17 00:00:00 2001 From: Luis Copetti Date: Thu, 9 Aug 2018 09:12:48 -0300 Subject: [PATCH] fix dom rendering of attributes with empty data (#289) (cherry picked from commit 294ed0218c787695d135b98e7b856371dc7a66a8) --- dtl/dom.js | 2 +- dtl/tests/dom/tag.js | 10 +++++++++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/dtl/dom.js b/dtl/dom.js index cbd7d8b383..91b67a4b86 100644 --- a/dtl/dom.js +++ b/dtl/dom.js @@ -916,7 +916,7 @@ define([ if(dd.BOOLS[key]){ value = !(value == "false" || value == "undefined" || !value); } - if(value !== this.contents){ + if(value !== this.contents || value === ""){ this.contents = value; return buffer.setAttribute(key, value); } diff --git a/dtl/tests/dom/tag.js b/dtl/tests/dom/tag.js index 2b915a86fa..b4edcaa6b7 100644 --- a/dtl/tests/dom/tag.js +++ b/dtl/tests/dom/tag.js @@ -320,6 +320,14 @@ doh.register("dojox.dtl.dom.tag", var template = new dd.DomTemplate('
'); //the following should not throw errors in IE dd.tests.dom.util.render(template, context); - } + }, + function test_attribute_with_empty_data(t){ + var dd = dojox.dtl; + + var template = new dd.DomTemplate('
'); + var context = new dd.Context({ fruit : "" }); + const htmlResult = template.render(context).getParent().outerHTML; + t.is('
', htmlResult); + }, ] ); \ No newline at end of file