Skip to content

Instantly share code, notes, and snippets.

@JBreit
Created February 15, 2017 04:09
Show Gist options
  • Save JBreit/da81ad809736b232a940bc5ebb3a8793 to your computer and use it in GitHub Desktop.
Save JBreit/da81ad809736b232a940bc5ebb3a8793 to your computer and use it in GitHub Desktop.
/*globals define*/
(function (global, factory) {
'use strict';
if (typeof define === 'function' && define.amd) {
define(['exports'], factory);
} else if (typeof exports === 'object' && typeof exports.nodeName !== 'string') {
factory(exports);
} else {
factory(global);
}
}(this, function (exports) {
'use strict';
var Component = function (_ref) {
if (!_ref) {
throw new Error('Component requires configuration.');
}
this.attributes = Object.create(null);
this.model = _ref.model;
this.view = _ref.view;
this.controller = _ref.controller;
};
Component.prototype = (function () {
var extend, initialize, get, mount, set, update;
extend = function (properties) {
var Child = Component.prototype,
keys = Object.keys(properties);
keys.forEach(function (key) {
Child.prototype = Component.prototype;
Child.prototype[key] = properties[key];
return Child;
});
};
initialize = function () {
console.log(this);
};
get = function (property) {
return this.attributes[property];
};
mount = function (_ref, root) {
console.log(typeof _ref);
console.log(typeof root);
console.log('mount method');
};
set = function (property, value) {
this.attributes[property] = value;
};
update = function () {
console.log('update');
};
return {
Constructor: Component,
extend: extend,
initalize: initialize,
get: get,
mount: mount,
set: set,
update: update
};
}());
Component.prototype.constructor = Component;
Component.prototype.extend = function (properties) {
var Child = Component.prototype,
keys = Object.keys(properties);
keys.forEach(function (key) {
Child.prototype = Component.prototype;
Child.prototype[key] = properties[key];
return Child;
});
};
Component.prototype.mount = function (_ref, root) {
console.log(typeof _ref);
console.log(typeof root);
console.log('mount method');
};
Component.prototype.update = function () {
console.log('update');
};
exports.Component = Component;
}));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment