From 9fafe9cda8bb289d65f388eb885506979c36b6bf Mon Sep 17 00:00:00 2001 From: cha0s Date: Sun, 7 Feb 2021 02:40:58 -0600 Subject: [PATCH] refactor: opt --- packages/graphics/src/traits/visible.js | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/packages/graphics/src/traits/visible.js b/packages/graphics/src/traits/visible.js index 38419bd..11fd6d6 100644 --- a/packages/graphics/src/traits/visible.js +++ b/packages/graphics/src/traits/visible.js @@ -266,11 +266,12 @@ export default () => class Visible extends decorate(Trait) { } onZIndexChanged(zIndex) { + if (!this.#container) { + return; + } this.#usingAutoZIndex = AUTO_ZINDEX === zIndex; if (!this.#usingAutoZIndex) { - if (this.#container) { - this.#container.zIndex = zIndex; - } + this.#container.zIndex = zIndex; } } @@ -335,9 +336,7 @@ export default () => class Visible extends decorate(Trait) { } this.#container.position = this.entity.position; if (this.#usingAutoZIndex) { - if (this.#container) { - this.#container.zIndex = this.entity.y; - } + this.#container.zIndex = this.entity.y; } }