Skip to content

Commit

Permalink
fix dom rendering of attributes with empty data (#289)
Browse files Browse the repository at this point in the history
(cherry picked from commit 294ed02)
  • Loading branch information
lhcopetti authored and dylans committed Aug 9, 2018
1 parent 9f42bf4 commit f3953e3
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
2 changes: 1 addition & 1 deletion dtl/dom.js
Expand Up @@ -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);
}
Expand Down
10 changes: 9 additions & 1 deletion dtl/tests/dom/tag.js
Expand Up @@ -320,6 +320,14 @@ doh.register("dojox.dtl.dom.tag",
var template = new dd.DomTemplate('<div tabIndex="-1"></div>');
//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('<div attr="{{fruit}}"></div>');
var context = new dd.Context({ fruit : "" });
const htmlResult = template.render(context).getParent().outerHTML;
t.is('<div attr=""></div>', htmlResult);
},
]
);

0 comments on commit f3953e3

Please sign in to comment.