feat(Container): add support for empty arrays passed to add

This commit is contained in:
Michaël De Boey 2022-10-17 00:31:55 +02:00 committed by GitHub
parent 578191d5d4
commit 57b8dc1566
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -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;
}