From: 三咲智子 Kevin Deng Date: Sat, 27 Jan 2024 17:39:16 +0000 (+0800) Subject: refactor(compiler-vapor): dedpue fragment X-Git-Tag: v3.6.0-alpha.1~16^2~651 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=9c9e9b2862bcddb5a359e9c5638b2f57243a6a3a;p=thirdparty%2Fvuejs%2Fcore.git refactor(compiler-vapor): dedpue fragment --- diff --git a/packages/compiler-vapor/src/transform.ts b/packages/compiler-vapor/src/transform.ts index f3b66da6d2..0c81c5e4c4 100644 --- a/packages/compiler-vapor/src/transform.ts +++ b/packages/compiler-vapor/src/transform.ts @@ -174,16 +174,17 @@ function createRootContext( registerTemplate() { let templateNode: TemplateFactoryIRNode | FragmentFactoryIRNode - if (this.template) { - const idx = root.template.findIndex( - (t) => - t.type === IRNodeTypes.TEMPLATE_FACTORY && - t.template === this.template, - ) - if (idx !== -1) { - return (this.block.templateIndex = idx) - } + const existing = root.template.findIndex((t) => + this.template + ? t.type === IRNodeTypes.TEMPLATE_FACTORY && + t.template === this.template + : t.type === IRNodeTypes.FRAGMENT_FACTORY, + ) + if (existing !== -1) { + return (this.block.templateIndex = existing) + } + if (this.template) { templateNode = { type: IRNodeTypes.TEMPLATE_FACTORY, template: this.template,