Clean up SkyElement

There's no reason to wrap this script in an anonymous function. Sky modules
already run inside their own scope.

R=rafaelw@chromium.org

Review URL: https://codereview.chromium.org/692253002
This commit is contained in:
Adam Barth 2014-10-31 14:58:38 -07:00
parent 03114dfa7e
commit 0b40ab943e

View File

@ -4,60 +4,51 @@
// found in the LICENSE file.
-->
<link rel="import" href="TemplateBinding.sky" />
<script>
(function(global) {
'use strict';
var Base = Object.create(HTMLElement.prototype, {
register: function() {
// |this| is prototype
var template = document.currentScript.previousElementSibling;
if (template && template.localName == 'template')
this.template_ = template;
},
var Base = {
createdCallback: function() {
},
__proto__: HTMLElement.prototype,
attachedCallback: function() {
var shadow = this.createShadowRoot();
shadow.appendChild(this.template_.createInstance(this));
this.attached();
},
register: function() {
// |this| is prototype
var template = document.currentScript.previousElementSibling;
if (template && template.localName == 'template') {
this.template_ = template;
}
},
attached: function() {
// override
},
createdCallback: function() {
},
dettachedCallback: function() {
this.dettached();
},
attachedCallback: function() {
var shadow = this.createShadowRoot();
shadow.appendChild(this.template_.createInstance(this));
this.attached();
},
dettached: function() {
// override
},
attached: function() {
// override
},
attributeChangedCallback: function(attrName, oldValue, newValue) {
// reserved for canonical behavior
this.attributeChanged(attrName, oldValue, newValue);
},
dettachedCallback: function() {
this.dettached();
},
attributeChanged: function(attrName, oldValue, newValue) {
// override
},
};
dettached: function() {
// override
},
function SkyElement(prototype) {
prototype.__proto__ = Base;
document.registerElement(prototype.name, { prototype: prototype });
prototype.register();
};
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);
module.exports = SkyElement;
</script>