Skip to content

Commit

Permalink
Exclude script and style tags for parsing bindings
Browse files Browse the repository at this point in the history
  • Loading branch information
TimvdLippe committed Sep 15, 2017
1 parent 00bc76e commit 41fa90b
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 0 deletions.
3 changes: 3 additions & 0 deletions lib/mixins/template-stamp.html
Original file line number Diff line number Diff line change
Expand Up @@ -256,6 +256,9 @@
* @param {!NodeInfo} nodeInfo Node metadata for current template.
*/
static _parseTemplateChildNodes(root, templateInfo, nodeInfo) {
if (root.localName === 'script' || root.localName === 'style') {
return;
}
for (let node=root.firstChild, parentIndex=0, next; node; node=next) {
// Wrap templates
if (node.localName == 'template') {
Expand Down
10 changes: 10 additions & 0 deletions test/unit/property-effects-elements.html
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,16 @@
literal1 {{cpnd1}} literal2 {{cpnd2}}{{cpnd3.prop}} literal3 {{computeCompound(cpnd4, cpnd5, 'literalComputed')}} literal4
</div>
<span id="boundWithDash">{{objectWithDash.binding-with-dash}}</span>
<script id="scriptWithBinding">
function foo() {
return "We have a {{binding}} here";
}
</script>
<style id="styleWithBinding">
:host {
content: '[[binding]]'
}
</style>
</template>
<script>
let ComputingBehavior = {
Expand Down
8 changes: 8 additions & 0 deletions test/unit/property-effects.html
Original file line number Diff line number Diff line change
Expand Up @@ -386,6 +386,14 @@
assert.equal(el.lateBoundObserver.firstCall.args[0], 'late');
});

test('does not parse bindings inside <script>', function() {
assert.include(el.$.scriptWithBinding.textContent, "{{binding}}");
});

test('does not parse bindings inside <style>', function() {
assert.include(el.shadowRoot.querySelector('style').textContent, "[[binding]]");
});

});

suite('computed bindings with dynamic functions', function() {
Expand Down

0 comments on commit 41fa90b

Please sign in to comment.