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

Unified Diff: sky/framework/sky-element/sky-element.sky

Issue 698653002: Add initial SkyElement & city-list example (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: ws Created 6 years, 2 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « sky/framework/sky-element/observe.sky ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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>
« no previous file with comments | « sky/framework/sky-element/observe.sky ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698