Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(783)

Unified Diff: sky/tests/framework/binding.sky

Issue 831033002: Add a basic SkyBinder test. (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 5 years, 12 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « sky/framework/dom-serializer.sky ('k') | sky/tests/framework/binding-expected.txt » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: sky/tests/framework/binding.sky
diff --git a/sky/tests/framework/binding.sky b/sky/tests/framework/binding.sky
new file mode 100644
index 0000000000000000000000000000000000000000..8a71ea526421dc93b338df07cdede672ea6d1190
--- /dev/null
+++ b/sky/tests/framework/binding.sky
@@ -0,0 +1,66 @@
+<!DOCTYPE html>
+
+<import src="/sky/framework/dom-serializer.sky" as="DomSerializer" />
+<import src="/sky/framework/sky-element/sky-binder.sky" as="binder" />
+
+<div id="host"></div>
+
+<template id="template">
+ <style>
+ .blue { border: 1px solid blue; }
+ .orange { border: 1px solid orange; }
+ .repeat { margin: 8px; }
+ </style>
+ <span style="color: {{ red }}">{{ value }}</span>
+ <template repeat="{{ list }}">
+ <div class="{{ className }} repeat">{{ item }}</div>
+ </template>
+ <template if="{{ test }}">
+ Hello World
+ </template>
+ <template if="{{ testFalse }}">
+ Should not be visible.
+ </template>
+ <template repeat="{{ nullInstances }}">
+ Should not be visible.
+ </template>
+ <div>{{ value }} test {{ red }}{{ className }} test</div>
+ <a href="{{ url }}">{{ url }}</a>
+ <span on-test-event="handleTestEvent">
+ <span id="target">Test event handler: </span>
+ </span>
+ <div class="[[ className ]]">[[ url ]]</div>
+</template>
+
+<script>
+window.addEventListener("load", function() {
+ var template = document.getElementById('template');
+ var host = document.getElementById('host');
+ host.handleTestEvent = function(e) {
+ e.target.appendChild(new Text("event dispatch success"));
+ };
+ window.model = {
+ value: 10,
+ test: true,
+ testFalse: false,
+ nullInstances: [null],
+ url: "http://www.google.com/",
+ red: "red",
+ className: "blue",
+ list: [{
+ item: "first",
+ className: "blue",
+ }, {
+ item: "second",
+ className: "orange",
+ }],
+ };
+ var instance = binder.createInstance(template, window.model);
+ host.ensureShadowRoot().appendChild(instance.fragment);
+ var target = host.shadowRoot.getElementById("target");
+ target.dispatchEvent(new CustomEvent("test-event", {
+ bubbles: true,
+ }));
+ internals.notifyTestComplete(DomSerializer.serializeNode(host.shadowRoot));
+});
+</script>
« no previous file with comments | « sky/framework/dom-serializer.sky ('k') | sky/tests/framework/binding-expected.txt » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698