OLD | NEW |
(Empty) | |
| 1 <!-- |
| 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 |
| 4 // found in the LICENSE file. |
| 5 --> |
| 6 <link rel="import" href="TemplateBinding.sky" /> |
| 7 |
| 8 <script> |
| 9 (function(global) { |
| 10 'use strict'; |
| 11 |
| 12 var Base = { |
| 13 |
| 14 __proto__: HTMLElement.prototype, |
| 15 |
| 16 register: function() { |
| 17 // |this| is prototype |
| 18 var template = document.currentScript.previousElementSibling; |
| 19 if (template && template.localName == 'template') { |
| 20 this.template_ = template; |
| 21 } |
| 22 }, |
| 23 |
| 24 createdCallback: function() { |
| 25 }, |
| 26 |
| 27 attachedCallback: function() { |
| 28 var shadow = this.createShadowRoot(); |
| 29 shadow.appendChild(this.template_.createInstance(this)); |
| 30 this.attached(); |
| 31 }, |
| 32 |
| 33 attached: function() { |
| 34 // override |
| 35 }, |
| 36 |
| 37 dettachedCallback: function() { |
| 38 this.dettached(); |
| 39 }, |
| 40 |
| 41 dettached: function() { |
| 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> |
OLD | NEW |