Index: sky/framework/sky-element/sky-element.sky |
diff --git a/sky/framework/sky-element/sky-element.sky b/sky/framework/sky-element/sky-element.sky |
new file mode 100644 |
index 0000000000000000000000000000000000000000..35578725d86c927f38e68d4fb4c08d1c2be3828f |
--- /dev/null |
+++ b/sky/framework/sky-element/sky-element.sky |
@@ -0,0 +1,63 @@ |
+<!-- |
+// Copyright 2014 The Chromium Authors. All rights reserved. |
+// Use of this source code is governed by a BSD-style license that can be |
+// found in the LICENSE file. |
+--> |
+<link rel="import" href="TemplateBinding.sky" /> |
+ |
+<script> |
+(function(global) { |
+ 'use strict'; |
+ |
+ var Base = { |
+ |
+ __proto__: HTMLElement.prototype, |
+ |
+ register: function() { |
+ // |this| is prototype |
+ var template = document.currentScript.previousElementSibling; |
+ if (template && template.localName == 'template') { |
+ this.template_ = template; |
+ } |
+ }, |
+ |
+ createdCallback: function() { |
+ }, |
+ |
+ attachedCallback: function() { |
+ var shadow = this.createShadowRoot(); |
+ shadow.appendChild(this.template_.createInstance(this)); |
+ this.attached(); |
+ }, |
+ |
+ attached: function() { |
+ // override |
+ }, |
+ |
+ dettachedCallback: function() { |
+ this.dettached(); |
+ }, |
+ |
+ dettached: function() { |
+ // override |
+ }, |
+ |
+ attributeChangedCallback: function(attrName, oldValue, newValue) { |
+ // reserved for canonical behavior |
+ this.attributeChanged(attrName, oldValue, newValue); |
+ }, |
+ |
+ attributeChanged: function(attrName, oldValue, newValue) { |
+ // override |
+ } |
+ }; |
+ |
+ function SkyElement(prototype) { |
+ prototype.__proto__ = Base; |
+ document.registerElement(prototype.name, { prototype: prototype }); |
+ prototype.register(); |
+ }; |
+ |
+ module.exports = SkyElement; |
+})(this); |
+</script> |