From 56b6bf3ebc82776c09650a822add940f5e136e82 Mon Sep 17 00:00:00 2001 From: Sergey Melnikov Date: Thu, 1 Apr 2021 16:19:47 -0400 Subject: [PATCH] spread is too slow (when compiled to es5) --- packages/react-testing/src/element.ts | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/packages/react-testing/src/element.ts b/packages/react-testing/src/element.ts index 2e9f786f31..37485ae075 100644 --- a/packages/react-testing/src/element.ts +++ b/packages/react-testing/src/element.ts @@ -256,12 +256,14 @@ function equalSubset(subset: object, full: object) { ); } -function getDescendants(element) { +function getDescendants(element: any) { const descendants: Element[] = []; // eslint-disable-next-line @typescript-eslint/prefer-for-of for (let i = 0; i < element.elementChildren.length; i++) { const child = element.elementChildren[i]; - descendants.push(child, ...getDescendants(child)); + descendants.push(child); + // eslint-disable-next-line prefer-spread + descendants.push.apply(descendants, child.elementDescendants); } return descendants;