Skip to content

Commit 41fa90b

Browse files
committed
Exclude script and style tags for parsing bindings
1 parent 00bc76e commit 41fa90b

3 files changed

Lines changed: 21 additions & 0 deletions

File tree

lib/mixins/template-stamp.html

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -256,6 +256,9 @@
256256
* @param {!NodeInfo} nodeInfo Node metadata for current template.
257257
*/
258258
static _parseTemplateChildNodes(root, templateInfo, nodeInfo) {
259+
if (root.localName === 'script' || root.localName === 'style') {
260+
return;
261+
}
259262
for (let node=root.firstChild, parentIndex=0, next; node; node=next) {
260263
// Wrap templates
261264
if (node.localName == 'template') {

test/unit/property-effects-elements.html

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,16 @@
6868
literal1 {{cpnd1}} literal2 {{cpnd2}}{{cpnd3.prop}} literal3 {{computeCompound(cpnd4, cpnd5, 'literalComputed')}} literal4
6969
</div>
7070
<span id="boundWithDash">{{objectWithDash.binding-with-dash}}</span>
71+
<script id="scriptWithBinding">
72+
function foo() {
73+
return "We have a {{binding}} here";
74+
}
75+
</script>
76+
<style id="styleWithBinding">
77+
:host {
78+
content: '[[binding]]'
79+
}
80+
</style>
7181
</template>
7282
<script>
7383
let ComputingBehavior = {

test/unit/property-effects.html

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -386,6 +386,14 @@
386386
assert.equal(el.lateBoundObserver.firstCall.args[0], 'late');
387387
});
388388

389+
test('does not parse bindings inside <script>', function() {
390+
assert.include(el.$.scriptWithBinding.textContent, "{{binding}}");
391+
});
392+
393+
test('does not parse bindings inside <style>', function() {
394+
assert.include(el.shadowRoot.querySelector('style').textContent, "[[binding]]");
395+
});
396+
389397
});
390398

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

0 commit comments

Comments
 (0)