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

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

Issue 692253002: Clean up SkyElement (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 6 years, 1 month 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 | 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 <link rel="import" href="TemplateBinding.sky" /> 6 <link rel="import" href="TemplateBinding.sky" />
7 <script>
8 var Base = Object.create(HTMLElement.prototype, {
9 register: function() {
10 // |this| is prototype
11 var template = document.currentScript.previousElementSibling;
12 if (template && template.localName == 'template')
13 this.template_ = template;
14 },
7 15
8 <script> 16 createdCallback: function() {
9 (function(global) { 17 },
10 'use strict';
11 18
12 var Base = { 19 attachedCallback: function() {
20 var shadow = this.createShadowRoot();
21 shadow.appendChild(this.template_.createInstance(this));
22 this.attached();
23 },
13 24
14 __proto__: HTMLElement.prototype, 25 attached: function() {
26 // override
27 },
15 28
16 register: function() { 29 dettachedCallback: function() {
17 // |this| is prototype 30 this.dettached();
18 var template = document.currentScript.previousElementSibling; 31 },
19 if (template && template.localName == 'template') {
20 this.template_ = template;
21 }
22 },
23 32
24 createdCallback: function() { 33 dettached: function() {
25 }, 34 // override
35 },
26 36
27 attachedCallback: function() { 37 attributeChangedCallback: function(attrName, oldValue, newValue) {
28 var shadow = this.createShadowRoot(); 38 // reserved for canonical behavior
29 shadow.appendChild(this.template_.createInstance(this)); 39 this.attributeChanged(attrName, oldValue, newValue);
30 this.attached(); 40 },
31 },
32 41
33 attached: function() { 42 attributeChanged: function(attrName, oldValue, newValue) {
34 // override 43 // override
35 }, 44 },
45 };
36 46
37 dettachedCallback: function() { 47 function SkyElement(prototype) {
38 this.dettached(); 48 prototype.__proto__ = Base;
39 }, 49 document.registerElement(prototype.name, { prototype: prototype });
50 prototype.register();
51 };
40 52
41 dettached: function() { 53 module.exports = SkyElement;
42 // override
43 },
44
45 attributeChangedCallback: function(attrName, oldValue, newValue) {
46 // reserved for canonical behavior
47 this.attributeChanged(attrName, oldValue, newValue);
48 },
49
50 attributeChanged: function(attrName, oldValue, newValue) {
51 // override
52 }
53 };
54
55 function SkyElement(prototype) {
56 prototype.__proto__ = Base;
57 document.registerElement(prototype.name, { prototype: prototype });
58 prototype.register();
59 };
60
61 module.exports = SkyElement;
62 })(this);
63 </script> 54 </script>
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698