From 04871e24d6fab1379e63b584dbdfad6fae9affc8 Mon Sep 17 00:00:00 2001 From: Christopher Willis-Ford Date: Fri, 16 Jun 2017 13:16:13 -0700 Subject: [PATCH] Move RenderedTarget.runtime into Target Some code in `Target` was already assuming a `runtime` property was available, so this change just makes it official. --- src/engine/target.js | 18 +++++++++++++----- src/sprites/rendered-target.js | 14 ++++++++------ 2 files changed, 21 insertions(+), 11 deletions(-) diff --git a/src/engine/target.js b/src/engine/target.js index c4f690aa9..398b484f2 100644 --- a/src/engine/target.js +++ b/src/engine/target.js @@ -11,17 +11,25 @@ const uid = require('../util/uid'); * Examples include sprites/clones or potentially physical-world devices. */ -/** - * @param {?Blocks} blocks Blocks instance for the blocks owned by this target. - * @constructor - */ class Target extends EventEmitter { - constructor (blocks) { + + /** + * @param {Runtime} runtime Reference to the runtime. + * @param {?Blocks} blocks Blocks instance for the blocks owned by this target. + * @constructor + */ + constructor (runtime, blocks) { super(); if (!blocks) { blocks = new Blocks(); } + + /** + * Reference to the runtime. + * @type {Runtime} + */ + this.runtime = runtime; /** * A unique ID for this target. * @type {string} diff --git a/src/sprites/rendered-target.js b/src/sprites/rendered-target.js index 2fb0ddf9e..af29be0fd 100644 --- a/src/sprites/rendered-target.js +++ b/src/sprites/rendered-target.js @@ -4,14 +4,16 @@ const Target = require('../engine/target'); /** * Rendered target: instance of a sprite (clone), or the stage. - * @param {!Sprite} sprite Reference to the parent sprite. - * @param {Runtime} runtime Reference to the runtime. - * @constructor */ class RenderedTarget extends Target { + /** + * @param {!Sprite} sprite Reference to the parent sprite. + * @param {Runtime} runtime Reference to the runtime. + * @constructor + */ constructor (sprite, runtime) { - super(sprite.blocks); - this.runtime = runtime; + super(runtime, sprite.blocks); + /** * Reference to the sprite that this is a render of. * @type {!Sprite} @@ -19,7 +21,7 @@ class RenderedTarget extends Target { this.sprite = sprite; /** * Reference to the global renderer for this VM, if one exists. - * @type {?RenderWebGLWorker} + * @type {?RenderWebGL} */ this.renderer = null; if (this.runtime) {