| OLD | NEW |
| 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 Loading... |
| 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> |
| OLD | NEW |