Skip to content

Commit

Permalink
Fix whitespace around bindings.
Browse files Browse the repository at this point in the history
  • Loading branch information
Steven Orvell committed Oct 28, 2015
1 parent 35a1b94 commit d7d0ed6
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/lib/annotations/annotations.html
Original file line number Diff line number Diff line change
Expand Up @@ -236,6 +236,8 @@
// optionally strip whitespace
if (stripWhiteSpace && !node.textContent.trim()) {
root.removeChild(node);
// decrement index since node is removed
i--;
}
}
// if this node didn't get evacipated, parse it.
Expand Down
38 changes: 38 additions & 0 deletions test/unit/template-whitespace.html
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,36 @@

</dom-module>

<dom-module id="no-whitespace-binding">

<template strip-whitespace>

<div id="text">{{text}}</div>
<div id="attr" attr$="{{attr}}">
<div>A</div>
</div>
<div>
<div>B</div>
</div>
<div id="compound"> {{a}} {{b}} </div>
</template>

<script>
HTMLImports.whenReady(function() {
Polymer({
properties: {
text: {value: 'text'},
attr: {value: 'attr'},
a: {value: 'a'},
b: {value: 'b'}
},
is: 'no-whitespace-binding'
});
});
</script>

</dom-module>



<script>
Expand Down Expand Up @@ -131,6 +161,14 @@
assert.equal(Polymer.dom(el.root).childNodes[1].childNodes.length, Polymer.dom(el.root).childNodes[1].children.length);
});

test('template with nested content stamped without whitespace when strip-template is used', function() {
var el = document.createElement('no-whitespace-binding');
document.body.appendChild(el);
assert.equal(el.$.text.textContent, 'text');
assert.equal(el.$.attr.getAttribute('attr'), 'attr');
assert.equal(el.$.compound.textContent, ' a b ');
});

});

</script>
Expand Down

0 comments on commit d7d0ed6

Please sign in to comment.