From 363d2585faa1f0a365f86b564a14440e5777e0cc Mon Sep 17 00:00:00 2001 From: Adam Bradley Date: Fri, 28 Aug 2020 12:40:42 -0500 Subject: [PATCH] fix(prerender): flatten hAsync children to resolve promises --- src/hydrate/platform/h-async.ts | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/hydrate/platform/h-async.ts b/src/hydrate/platform/h-async.ts index ed99749ee44..b420b117f7f 100644 --- a/src/hydrate/platform/h-async.ts +++ b/src/hydrate/platform/h-async.ts @@ -1,15 +1,16 @@ -import * as d from '../../declarations'; +import type * as d from '../../declarations'; +import { consoleDevError } from '@platform'; import { h } from '@runtime'; import { isPromise } from '@utils'; -import { consoleDevError } from '@platform'; export const hAsync = (nodeName: any, vnodeData: any, ...children: d.ChildType[]) => { if (Array.isArray(children) && children.length > 0) { // only return a promise if we have to - if (children.some(isPromise)) { + const flatChildren = children.flat(Infinity); + if (flatChildren.some(isPromise)) { // has children and at least one of them is async // wait on all of them to be resolved - return Promise.all(children) + return Promise.all(flatChildren) .then(resolvedChildren => { return h(nodeName, vnodeData, ...resolvedChildren); })