From 57b8dc15664f4d20e3429e982dc125a47974b71b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C3=ABl=20De=20Boey?= Date: Mon, 17 Oct 2022 00:31:55 +0200 Subject: [PATCH] feat(Container): add support for empty arrays passed to `add` --- src/Container.ts | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/Container.ts b/src/Container.ts index 69fb545a..bcaea798 100644 --- a/src/Container.ts +++ b/src/Container.ts @@ -118,9 +118,12 @@ export abstract class Container< * layer.draw(); */ add(...children: ChildType[]) { - if (arguments.length > 1) { - for (var i = 0; i < arguments.length; i++) { - this.add(arguments[i]); + if (children.length === 0) { + return this; + } + if (children.length > 1) { + for (var i = 0; i < children.length; i++) { + this.add(children[i]); } return this; }