diff --git a/.eslintrc.json b/.eslintrc.json index 861bdd0..c606c69 100644 --- a/.eslintrc.json +++ b/.eslintrc.json @@ -238,7 +238,7 @@ "prefer-arrow-callback": 0, "prefer-const": 2, "prefer-reflect": 0, - "prefer-rest-params": 2, + "prefer-rest-params": 0, "prefer-spread": 0, "prefer-template": 2, "require-yield": 2, diff --git a/.eslintrc.json b/.eslintrc.json index 861bdd0..c606c69 100644 --- a/.eslintrc.json +++ b/.eslintrc.json @@ -238,7 +238,7 @@ "prefer-arrow-callback": 0, "prefer-const": 2, "prefer-reflect": 0, - "prefer-rest-params": 2, + "prefer-rest-params": 0, "prefer-spread": 0, "prefer-template": 2, "require-yield": 2, diff --git a/src/core/display/Container.js b/src/core/display/Container.js index e8f7832..57b430f 100644 --- a/src/core/display/Container.js +++ b/src/core/display/Container.js @@ -50,12 +50,22 @@ * @param {...PIXI.DisplayObject} child - The DisplayObject(s) to add to the container * @return {PIXI.DisplayObject} The first child that was added. */ - addChild(...childs) + addChild(child) { - for (let i = 0; i < childs.length; ++i) - { - const child = childs[i]; + const argumentsLength = arguments.length; + // if there is only one argument we can bypass looping through the them + if (argumentsLength > 1) + { + // loop through the arguments property and add all children + // use it the right way (.length and [i]) so that this function can still be optimised by JS runtimes + for (let i = 0; i < argumentsLength; i++) + { + this.addChild(arguments[i]); + } + } + else + { // if the child has a parent then lets remove it as Pixi objects can only exist in one place if (child.parent) { @@ -64,10 +74,6 @@ child.parent = this; - // ensure a transform will be recalculated.. - this.transform._parentID = -1; - this._boundsID++; - this.children.push(child); // TODO - lets either do all callbacks or all events.. not both! @@ -75,7 +81,7 @@ child.emit('added', this); } - return childs[0]; + return child; } /**