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

Side by Side Diff: sky/framework/sky-element/sky-element.sky

Issue 821353003: Switch to SkyBinder (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 5 years, 11 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 unified diff | Download patch
« no previous file with comments | « sky/framework/sky-element/sky-binder.sky ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 <!-- 1 <!--
2 // Copyright 2014 The Chromium Authors. All rights reserved. 2 // Copyright 2014 The Chromium Authors. All rights reserved.
3 // Use of this source code is governed by a BSD-style license that can be 3 // Use of this source code is governed by a BSD-style license that can be
4 // found in the LICENSE file. 4 // found in the LICENSE file.
5 --> 5 -->
6 <import src="TemplateBinding.sky" /> 6 <import src="sky-binder.sky" as="binder" />
7 <script> 7 <script>
8 var templates = new Map(); 8 var templates = new Map();
9 9
10 class SkyElement extends HTMLElement { 10 class SkyElement extends HTMLElement {
11 11
12 static register() { 12 static register() {
13 var wrapper = document.currentScript.parentNode; 13 var wrapper = document.currentScript.parentNode;
14 14
15 if (wrapper.localName !== 'sky-element') 15 if (wrapper.localName !== 'sky-element')
16 throw new Error('No <sky-element>.'); 16 throw new Error('No <sky-element>.');
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
50 50
51 createdCallback() { 51 createdCallback() {
52 this.created(); 52 this.created();
53 } 53 }
54 54
55 attachedCallback() { 55 attachedCallback() {
56 if (!this.shadowRoot) { 56 if (!this.shadowRoot) {
57 var template = templates.get(this.localName); 57 var template = templates.get(this.localName);
58 if (template) { 58 if (template) {
59 var shadow = this.ensureShadowRoot(); 59 var shadow = this.ensureShadowRoot();
60 shadow.appendChild(template.createInstance(this)); 60 var instance = binder.createInstance(template, this);
61 shadow.appendChild(instance.fragment);
61 this.shadowRootReady(); 62 this.shadowRootReady();
62 } 63 }
63 } 64 }
64 this.attached(); 65 this.attached();
65 } 66 }
66 67
67 dettachedCallback() { 68 dettachedCallback() {
68 this.dettached(); 69 this.dettached();
69 } 70 }
70 71
71 attributeChangedCallback(attrName, oldValue, newValue) { 72 attributeChangedCallback(attrName, oldValue, newValue) {
72 // reserved for canonical behavior 73 // reserved for canonical behavior
73 this.attributeChanged(attrName, oldValue, newValue); 74 this.attributeChanged(attrName, oldValue, newValue);
74 } 75 }
75 }; 76 };
76 77
77 module.exports = SkyElement; 78 module.exports = SkyElement;
78 </script> 79 </script>
OLDNEW
« no previous file with comments | « sky/framework/sky-element/sky-binder.sky ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698