Skip to content

Commit

Permalink
refact: Make DOMElement inherit from Component
Browse files Browse the repository at this point in the history
  • Loading branch information
alexanderGugel committed Jun 2, 2015
1 parent c679187 commit acfebab
Showing 1 changed file with 7 additions and 19 deletions.
26 changes: 7 additions & 19 deletions dom-renderables/DOMElement.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
'use strict';

var CallbackStore = require('../utilities/CallbackStore');
var Component = require('../core/Component');

var RENDER_SIZE = 2;

Expand All @@ -34,6 +35,7 @@ var RENDER_SIZE = 2;
* to through their Nodes to the Compositor where they are acted upon.
*
* @class DOMElement
* @augments Component
*
* @param {Node} node The Node to which the `DOMElement`
* renderable should be attached to.
Expand All @@ -52,13 +54,11 @@ var RENDER_SIZE = 2;
* for DOM and WebGL layering. On by default.
*/
function DOMElement(node, options) {
if (!node) throw new Error('DOMElement must be instantiated on a node');
Component.call(this, node);

this._node = node;
this._parent = null;
this._children = [];

this._requestingUpdate = false;
this._renderSized = false;
this._requestRenderSize = false;

Expand Down Expand Up @@ -105,6 +105,9 @@ function DOMElement(node, options) {
if (options.cutout === false) this.setCutoutState(options.cutout);
}

DOMElement.prototype = Object.create(Component.prototype);
DOMElement.prototype.constructor = DOMElement;

/**
* Serializes the state of the DOMElement.
*
Expand Down Expand Up @@ -152,7 +155,7 @@ DOMElement.prototype.onUpdate = function onUpdate() {

}

this._requestingUpdate = false;
Component.prototype.onUpdate.call(this);
};

/**
Expand Down Expand Up @@ -425,21 +428,6 @@ DOMElement.prototype.getRenderSize = function getRenderSize() {
return this._renderSize;
};

/**
* Method to have the component request an update from its Node
*
* @method
* @private
*
* @return {undefined} undefined
*/
DOMElement.prototype._requestUpdate = function _requestUpdate() {
if (!this._requestingUpdate) {
this._node.requestUpdate(this._id);
this._requestingUpdate = true;
}
};

/**
* Initializes the DOMElement by sending the `INIT_DOM` command. This creates
* or reallocates a new Element in the actual DOM hierarchy.
Expand Down

0 comments on commit acfebab

Please sign in to comment.