Skip to content

Commit

Permalink
remove data-bind when it's empty
Browse files Browse the repository at this point in the history
  • Loading branch information
bago committed Feb 15, 2019
1 parent 2f8c78c commit 5b4dc1b
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
2 changes: 1 addition & 1 deletion spec/converter-spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ describe('Template converter', function() {
var expectedTemplates = [{
optionalName: 'template',
templateMode: 'show',
html: '<replacedhtml data-bind=""><replacedhead></replacedhead><repleacedbody><div data-bind="block: mainBlocks"></div></repleacedbody></replacedhtml>'
html: '<replacedhtml><replacedhead></replacedhead><repleacedbody><div data-bind="block: mainBlocks"></div></repleacedbody></replacedhtml>'
}, {
optionalName: 'simpleBlock',
templateMode: 'show',
Expand Down
3 changes: 2 additions & 1 deletion src/js/converter/declarations.js
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,8 @@ var elaborateDeclarations = function(style, declarations, templateUrlConverter,

var currentBindings = domutils.getAttribute(element, 'data-bind');
var dataBind = (currentBindings !== null ? currentBindings + ", " : "") + _bindingSerializer(newBindings);
domutils.setAttribute(element, 'data-bind', dataBind);
if (dataBind == '') domutils.removeAttribute(element, 'data-bind');
else domutils.setAttribute(element, 'data-bind', dataBind);
}

// TODO a function whose return type depends on the input parameters is very ugly.. please FIX ME.
Expand Down

0 comments on commit 5b4dc1b

Please sign in to comment.