Skip to content

Commit

Permalink
Fix rendering for value attribute on option tag (#296)
Browse files Browse the repository at this point in the history
  • Loading branch information
lhcopetti authored and dylans committed Feb 16, 2019
1 parent ddcbf3f commit c5cc54b
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 3 deletions.
3 changes: 0 additions & 3 deletions dtl/dom.js
Original file line number Diff line number Diff line change
Expand Up @@ -223,9 +223,6 @@ define([
value = node.className || value;
}else if(key == "for"){
value = node.htmlFor || value;
}else if(key == "value" && node.value == node.innerHTML){
// Sometimes .value is set the same as the contents of the item (button)
continue;
}else if(node.getAttribute){
value = node.getAttribute(key, 2) || value;
if(key == "href" || key == "src"){
Expand Down
20 changes: 20 additions & 0 deletions dtl/tests/dom/tag.js
Original file line number Diff line number Diff line change
Expand Up @@ -329,5 +329,25 @@ doh.register("dojox.dtl.dom.tag",
const htmlResult = template.render(context).getParent().outerHTML;
t.is('<div attr=""></div>', htmlResult);
},
function test_option_tag_with_same_value_attribute_and_innerHTML(t){
var dd = dojox.dtl;

const html =
'<div>'
+ '<select>'
+ '<option value="{{fruit}}">{{fruit}}</option>'
+ '</select>'
+ '</div>';
var template = new dd.DomTemplate(html);
var context = new dd.Context({ fruit : "Fruit" });
const htmlResult = template.render(context).getParent().outerHTML;
const htmlExpected =
'<div>'
+ '<select>'
+ '<option value="Fruit">Fruit</option>'
+ '</select>'
+ '</div>';
t.is(htmlExpected, htmlResult);
},
]
);

0 comments on commit c5cc54b

Please sign in to comment.