diff --git a/packages/runtime-vapor/src/dom/template.ts b/packages/runtime-vapor/src/dom/template.ts index 4b22e508c..bab7d5e17 100644 --- a/packages/runtime-vapor/src/dom/template.ts +++ b/packages/runtime-vapor/src/dom/template.ts @@ -13,9 +13,14 @@ export function template(html: string) { /*! #__NO_SIDE_EFFECTS__ */ export function children(node: Node, ...paths: number[]): Node { for (const idx of paths) { - for (let i = 0; i <= idx; i++) { - node = node[i === 0 ? 'firstChild' : 'nextSibling']! - } + // In various situations, select the quickest approach. + // See https://github.com/vuejs/core-vapor/pull/263 + node = + idx === 0 + ? node.firstChild! + : idx === 1 + ? node.firstChild!.nextSibling! + : node.childNodes[idx] } return node }