Skip to content

Commit

Permalink
Ensure template is decorated before stamping shadowRoot, fixes Polyme…
Browse files Browse the repository at this point in the history
  • Loading branch information
sorvell committed Aug 14, 2014
1 parent fc07839 commit 73801fc
Show file tree
Hide file tree
Showing 4 changed files with 80 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/instance/mdv.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@
// element api supporting mdv
var mdv = {
instanceTemplate: function(template) {
// ensure template is decorated (lets' things like <tr template ...> work)
HTMLTemplateElement.decorate(template);
// ensure a default bindingDelegate
var syntax = this.syntax || (!template.bindingDelegate &&
this.element.syntax);
Expand Down
19 changes: 19 additions & 0 deletions test/html/template-attr-template-import.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<polymer-element name="decoration-test">
<template>
<select id="select">
<option template repeat="{{opt in options}}" value="{{opt}}">{{opt}}</option>
</select>
</template>
<script>
Polymer('decoration-test', {
options: [1, 2, 3, 4],
ready: function() {
this.test();
testsRun++;
},
test: function() {
chai.assert.equal(this.$.select.children.length, 5, 'attribute template stamped');
}
});
</script>
</polymer-element>
58 changes: 58 additions & 0 deletions test/html/template-attr-template.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
<!doctype html>
<!--
Copyright (c) 2014 The Polymer Project Authors. All rights reserved.
This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt
The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt
The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt
Code distributed by Google as part of the polymer project is also
subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt
-->
<script src="../../../platform/platform.js"></script>
<link rel="import" href="../../polymer.html">
<link rel="import" href="template-attr-template-import.html">
<script src="../../../tools/test/htmltest.js"></script>
<script src="../../../tools/test/chai/chai.js"></script>
<script>
var testsRun = 0;
</script>


<polymer-element name="decoration-test2" extends="decoration-test">
<template>
<table>
<thead>
<th>one</th>
<th>two</th>
<th>three</th>
</thead>
<tbody id="tbody">
<tr template repeat="{{ arr in arrs }}">
<td template repeat="{{ n in arr }}">
{{n}}
</td>
</tr>
</tbody>
</table>
</template>
<script>
Polymer('decoration-test2', {
arrs: [ [1,2,3], [4,5,6] ],
test: function() {
chai.assert.equal(this.$.tbody.children.length, 3, 'attribute template stamped');
chai.assert.equal(this.$.tbody.children[1].children.length, 4, 'attribute sub-template stamped');
}
});
</script>
</polymer-element>

<decoration-test></decoration-test>
<br>
<decoration-test2></decoration-test2>


<script>
document.addEventListener('polymer-ready', function() {
chai.assert.equal(testsRun, 2, 'decration tests ran');
done();
});
</script>
1 change: 1 addition & 0 deletions test/js/bindMDV.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ suite('bindMDV', function() {

htmlSuite('bind', function() {
htmlTest('html/template-distribute-dynamic.html');
htmlTest('html/template-attr-template.html');
htmlTest('html/bind.html');
htmlTest('html/unbind.html');
htmlTest('html/prop-attr-bind-reflection.html');
Expand Down

0 comments on commit 73801fc

Please sign in to comment.