Skip to content

Commit e78d68e

Browse files
refact: Make DOMElement inherit from Component
1 parent f355e71 commit e78d68e

File tree

1 file changed

+7
-20
lines changed

1 file changed

+7
-20
lines changed

dom-renderables/DOMElement.js

Lines changed: 7 additions & 20 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,11 +54,8 @@ 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;
58-
59-
this._requestingUpdate = false;
6059
this._renderSized = false;
6160
this._requestRenderSize = false;
6261

@@ -102,6 +101,9 @@ function DOMElement(node, options) {
102101
if (options.cutout === false) this.setCutoutState(options.cutout);
103102
}
104103

104+
DOMElement.prototype = Object.create(Component.prototype);
105+
DOMElement.prototype.constructor = DOMElement;
106+
105107
/**
106108
* Serializes the state of the DOMElement.
107109
*
@@ -149,7 +151,7 @@ DOMElement.prototype.onUpdate = function onUpdate() {
149151

150152
}
151153

152-
this._requestingUpdate = false;
154+
Component.prototype.onUpdate.call(this);
153155
};
154156

155157
/**
@@ -356,21 +358,6 @@ DOMElement.prototype.getRenderSize = function getRenderSize() {
356358
return this._renderSize;
357359
};
358360

359-
/**
360-
* Method to have the component request an update from its Node
361-
*
362-
* @method
363-
* @private
364-
*
365-
* @return {undefined} undefined
366-
*/
367-
DOMElement.prototype._requestUpdate = function _requestUpdate() {
368-
if (!this._requestingUpdate) {
369-
this._node.requestUpdate(this._id);
370-
this._requestingUpdate = true;
371-
}
372-
};
373-
374361
/**
375362
* Initializes the DOMElement by sending the `INIT_DOM` command. This creates
376363
* or reallocates a new Element in the actual DOM hierarchy.

0 commit comments

Comments
 (0)