Skip to content

Commit acfebab

Browse files
refact: Make DOMElement inherit from Component
1 parent c679187 commit acfebab

File tree

1 file changed

+7
-19
lines changed

1 file changed

+7
-19
lines changed

dom-renderables/DOMElement.js

Lines changed: 7 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
'use strict';
2626

2727
var CallbackStore = require('../utilities/CallbackStore');
28+
var Component = require('../core/Component');
2829

2930
var RENDER_SIZE = 2;
3031

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

57-
this._node = node;
5859
this._parent = null;
5960
this._children = [];
6061

61-
this._requestingUpdate = false;
6262
this._renderSized = false;
6363
this._requestRenderSize = false;
6464

@@ -105,6 +105,9 @@ function DOMElement(node, options) {
105105
if (options.cutout === false) this.setCutoutState(options.cutout);
106106
}
107107

108+
DOMElement.prototype = Object.create(Component.prototype);
109+
DOMElement.prototype.constructor = DOMElement;
110+
108111
/**
109112
* Serializes the state of the DOMElement.
110113
*
@@ -152,7 +155,7 @@ DOMElement.prototype.onUpdate = function onUpdate() {
152155

153156
}
154157

155-
this._requestingUpdate = false;
158+
Component.prototype.onUpdate.call(this);
156159
};
157160

158161
/**
@@ -425,21 +428,6 @@ DOMElement.prototype.getRenderSize = function getRenderSize() {
425428
return this._renderSize;
426429
};
427430

428-
/**
429-
* Method to have the component request an update from its Node
430-
*
431-
* @method
432-
* @private
433-
*
434-
* @return {undefined} undefined
435-
*/
436-
DOMElement.prototype._requestUpdate = function _requestUpdate() {
437-
if (!this._requestingUpdate) {
438-
this._node.requestUpdate(this._id);
439-
this._requestingUpdate = true;
440-
}
441-
};
442-
443431
/**
444432
* Initializes the DOMElement by sending the `INIT_DOM` command. This creates
445433
* or reallocates a new Element in the actual DOM hierarchy.

0 commit comments

Comments
 (0)