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

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

Issue 806133003: Fix detached callback and add isAttached to SkyElements. (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Don't hide state for now. 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 | « no previous file | sky/tests/framework/templates.sky » ('j') | 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="sky-binder.sky" as="binder" /> 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 {
(...skipping 18 matching lines...) Expand all
29 } 29 }
30 30
31 created() { 31 created() {
32 // override 32 // override
33 } 33 }
34 34
35 attached() { 35 attached() {
36 // override 36 // override
37 } 37 }
38 38
39 dettached() { 39 detached() {
40 // override 40 // override
41 } 41 }
42 42
43 attributeChanged(attrName, oldValue, newValue) { 43 attributeChanged(attrName, oldValue, newValue) {
44 // override 44 // override
45 } 45 }
46 46
47 shadowRootReady() { 47 shadowRootReady() {
48 // override 48 // override
49 } 49 }
50 50
51 createdCallback() { 51 createdCallback() {
52 this.isAttached = false;
52 this.created(); 53 this.created();
53 } 54 }
54 55
55 attachedCallback() { 56 attachedCallback() {
56 if (!this.shadowRoot) { 57 if (!this.shadowRoot) {
57 var template = templates.get(this.localName); 58 var template = templates.get(this.localName);
58 if (template) { 59 if (template) {
59 var shadow = this.ensureShadowRoot(); 60 var shadow = this.ensureShadowRoot();
60 var instance = binder.createInstance(template, this); 61 var instance = binder.createInstance(template, this);
61 shadow.appendChild(instance.fragment); 62 shadow.appendChild(instance.fragment);
62 this.shadowRootReady(); 63 this.shadowRootReady();
63 } 64 }
64 } 65 }
65 this.attached(); 66 this.attached();
67 this.isAttached = true;
66 } 68 }
67 69
68 dettachedCallback() { 70 detachedCallback() {
69 this.dettached(); 71 this.detached();
72 this.isAttached = false;
70 } 73 }
71 74
72 attributeChangedCallback(attrName, oldValue, newValue) { 75 attributeChangedCallback(attrName, oldValue, newValue) {
73 // reserved for canonical behavior 76 // reserved for canonical behavior
74 this.attributeChanged(attrName, oldValue, newValue); 77 this.attributeChanged(attrName, oldValue, newValue);
75 } 78 }
76 }; 79 };
77 80
78 module.exports = SkyElement; 81 module.exports = SkyElement;
79 </script> 82 </script>
OLDNEW
« no previous file with comments | « no previous file | sky/tests/framework/templates.sky » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698