| OLD | NEW |
| (Empty) |
| 1 <!DOCTYPE html> | |
| 2 | |
| 3 <import src="/sky/framework/dom-serializer.sky" as="DomSerializer" /> | |
| 4 <import src="/sky/framework/elements/sky-element/sky-binder.sky" as="binder" /> | |
| 5 | |
| 6 <div id="host"></div> | |
| 7 | |
| 8 <template id="template"> | |
| 9 <style> | |
| 10 .blue { border: 1px solid blue; } | |
| 11 .orange { border: 1px solid orange; } | |
| 12 .repeat { margin: 8px; } | |
| 13 </style> | |
| 14 <span style="color: {{ red }}">{{ value }}</span> | |
| 15 <template repeat="{{ list }}"> | |
| 16 <div class="{{ className }} repeat">{{ item }}</div> | |
| 17 </template> | |
| 18 <template if="{{ test }}"> | |
| 19 Hello World | |
| 20 </template> | |
| 21 <template if="{{ testFalse }}"> | |
| 22 Should not be visible. | |
| 23 </template> | |
| 24 <template repeat="{{ nullInstances }}"> | |
| 25 Should not be visible. | |
| 26 </template> | |
| 27 <div>{{ value }} test {{ red }}{{ className }} test</div> | |
| 28 <a href="{{ url }}">{{ url }}</a> | |
| 29 <span on-test-event="handleTestEvent"> | |
| 30 <span id="target">Test event handler: </span> | |
| 31 </span> | |
| 32 <div class="[[ className ]]">[[ url ]]</div> | |
| 33 </template> | |
| 34 | |
| 35 <script> | |
| 36 window.addEventListener("load", function() { | |
| 37 var template = document.getElementById('template'); | |
| 38 var host = document.getElementById('host'); | |
| 39 host.handleTestEvent = function(e) { | |
| 40 e.target.appendChild(new Text("event dispatch success")); | |
| 41 }; | |
| 42 window.model = { | |
| 43 value: 10, | |
| 44 test: true, | |
| 45 testFalse: false, | |
| 46 nullInstances: [null], | |
| 47 url: "http://www.google.com/", | |
| 48 red: "red", | |
| 49 className: "blue", | |
| 50 list: [{ | |
| 51 item: "first", | |
| 52 className: "blue", | |
| 53 }, { | |
| 54 item: "second", | |
| 55 className: "orange", | |
| 56 }], | |
| 57 }; | |
| 58 var instance = binder.createInstance(template, window.model); | |
| 59 host.ensureShadowRoot().appendChild(instance.fragment); | |
| 60 var target = host.shadowRoot.getElementById("target"); | |
| 61 target.dispatchEvent(new CustomEvent("test-event", { | |
| 62 bubbles: true, | |
| 63 })); | |
| 64 internals.notifyTestComplete(DomSerializer.serializeNode(host.shadowRoot)); | |
| 65 }); | |
| 66 </script> | |
| OLD | NEW |