From ceff89905b05381d3d73c480e08c7aff9271b074 Mon Sep 17 00:00:00 2001 From: HcySunYang Date: Wed, 23 Jun 2021 07:15:20 +0800 Subject: [PATCH] perf: improve VNode creation performance with compiler hints (#3334) --- .../__snapshots__/codegen.spec.ts.snap | 8 +- .../__snapshots__/compile.spec.ts.snap | 48 ++-- .../__snapshots__/scopeId.spec.ts.snap | 22 +- .../compiler-core/__tests__/codegen.spec.ts | 27 ++- .../compiler-core/__tests__/scopeId.spec.ts | 4 +- packages/compiler-core/__tests__/testUtils.ts | 20 +- .../__snapshots__/hoistStatic.spec.ts.snap | 182 +++++++------- .../transformExpressions.spec.ts.snap | 6 +- .../__snapshots__/transformText.spec.ts.snap | 36 +-- .../__snapshots__/vFor.spec.ts.snap | 90 +++---- .../transforms/__snapshots__/vIf.spec.ts.snap | 54 ++--- .../__snapshots__/vModel.spec.ts.snap | 36 +-- .../__snapshots__/vOnce.spec.ts.snap | 24 +- .../__snapshots__/vSlot.spec.ts.snap | 12 +- .../__tests__/transforms/hoistStatic.spec.ts | 19 +- .../transforms/transformElement.spec.ts | 82 +++++-- .../__tests__/transforms/vBind.spec.ts | 72 ++++-- .../__tests__/transforms/vIf.spec.ts | 11 +- .../__tests__/transforms/vModel.spec.ts | 156 ++++++------ packages/compiler-core/src/ast.ts | 10 +- packages/compiler-core/src/codegen.ts | 18 +- packages/compiler-core/src/options.ts | 16 +- packages/compiler-core/src/runtimeHelpers.ts | 12 + packages/compiler-core/src/transform.ts | 16 +- .../src/transforms/hoistStatic.ts | 53 +++- .../src/transforms/transformElement.ts | 91 ++++++- packages/compiler-core/src/transforms/vFor.ts | 30 ++- packages/compiler-core/src/transforms/vIf.ts | 20 +- packages/compiler-core/src/utils.ts | 81 ++++++- .../__snapshots__/index.spec.ts.snap | 16 +- .../__snapshots__/vModel.spec.ts.snap | 52 ++-- .../__snapshots__/vShow.spec.ts.snap | 4 +- .../warnTransitionChildren.spec.ts.snap | 14 +- .../__snapshots__/compileScript.spec.ts.snap | 74 +++--- .../compileTemplate.spec.ts.snap | 2 +- .../templateTransformAssetUrl.spec.ts.snap | 62 ++--- .../templateTransformSrcset.spec.ts.snap | 84 +++---- packages/compiler-ssr/src/index.ts | 1 + .../src/transforms/ssrTransformComponent.ts | 1 + packages/runtime-core/src/index.ts | 10 +- packages/runtime-core/src/vnode.ts | 227 ++++++++++++------ packages/shared/src/normalizeProp.ts | 12 + 42 files changed, 1130 insertions(+), 685 deletions(-) diff --git a/packages/compiler-core/__tests__/__snapshots__/codegen.spec.ts.snap b/packages/compiler-core/__tests__/__snapshots__/codegen.spec.ts.snap index 74d0ab70d38..c292b032934 100644 --- a/packages/compiler-core/__tests__/__snapshots__/codegen.spec.ts.snap +++ b/packages/compiler-core/__tests__/__snapshots__/codegen.spec.ts.snap @@ -48,12 +48,12 @@ exports[`compiler: codegen Element (callExpression + objectExpression + Template " return function render(_ctx, _cache) { with (_ctx) { - return _createVNode(\\"div\\", { + return _createElementVNode(\\"div\\", { id: \\"foo\\", [prop]: bar, [foo + bar]: bar }, [ - _createVNode(\\"p\\", { \\"some-key\\": \\"foo\\" }) + _createElementVNode(\\"p\\", { \\"some-key\\": \\"foo\\" }) ], 16) } }" @@ -98,7 +98,7 @@ exports[`compiler: codegen forNode 1`] = ` " return function render(_ctx, _cache) { with (_ctx) { - return (_openBlock(true), _createBlock(_Fragment, null, _renderList(), 1)) + return (_openBlock(true), _createElementBlock(_Fragment, null, _renderList(), 1)) } }" `; @@ -107,7 +107,7 @@ exports[`compiler: codegen forNode with constant expression 1`] = ` " return function render(_ctx, _cache) { with (_ctx) { - return (_openBlock(), _createBlock(_Fragment, null, _renderList(), 64 /* STABLE_FRAGMENT */)) + return (_openBlock(), _createElementBlock(_Fragment, null, _renderList(), 64 /* STABLE_FRAGMENT */)) } }" `; diff --git a/packages/compiler-core/__tests__/__snapshots__/compile.spec.ts.snap b/packages/compiler-core/__tests__/__snapshots__/compile.spec.ts.snap index 6879301b64d..a72a43782ce 100644 --- a/packages/compiler-core/__tests__/__snapshots__/compile.spec.ts.snap +++ b/packages/compiler-core/__tests__/__snapshots__/compile.spec.ts.snap @@ -5,21 +5,21 @@ exports[`compiler: integration tests function mode 1`] = ` return function render(_ctx, _cache) { with (_ctx) { - const { toDisplayString: _toDisplayString, openBlock: _openBlock, createBlock: _createBlock, createCommentVNode: _createCommentVNode, createTextVNode: _createTextVNode, Fragment: _Fragment, renderList: _renderList, createVNode: _createVNode } = _Vue + const { toDisplayString: _toDisplayString, openBlock: _openBlock, createElementBlock: _createElementBlock, createCommentVNode: _createCommentVNode, createTextVNode: _createTextVNode, Fragment: _Fragment, renderList: _renderList, createElementVNode: _createElementVNode, normalizeClass: _normalizeClass } = _Vue - return (_openBlock(), _createBlock(\\"div\\", { + return (_openBlock(), _createElementBlock(\\"div\\", { id: \\"foo\\", - class: bar.baz + class: _normalizeClass(bar.baz) }, [ _createTextVNode(_toDisplayString(world.burn()) + \\" \\", 1 /* TEXT */), ok - ? (_openBlock(), _createBlock(\\"div\\", { key: 0 }, \\"yes\\")) - : (_openBlock(), _createBlock(_Fragment, { key: 1 }, [ + ? (_openBlock(), _createElementBlock(\\"div\\", { key: 0 }, \\"yes\\")) + : (_openBlock(), _createElementBlock(_Fragment, { key: 1 }, [ _createTextVNode(\\"no\\") ], 2112 /* STABLE_FRAGMENT, DEV_ROOT_FRAGMENT */)), - (_openBlock(true), _createBlock(_Fragment, null, _renderList(list, (value, index) => { - return (_openBlock(), _createBlock(\\"div\\", null, [ - _createVNode(\\"span\\", null, _toDisplayString(value + index), 1 /* TEXT */) + (_openBlock(true), _createElementBlock(_Fragment, null, _renderList(list, (value, index) => { + return (_openBlock(), _createElementBlock(\\"div\\", null, [ + _createElementVNode(\\"span\\", null, _toDisplayString(value + index), 1 /* TEXT */) ])) }), 256 /* UNKEYED_FRAGMENT */)) ], 2 /* CLASS */)) @@ -28,22 +28,22 @@ return function render(_ctx, _cache) { `; exports[`compiler: integration tests function mode w/ prefixIdentifiers: true 1`] = ` -"const { toDisplayString: _toDisplayString, openBlock: _openBlock, createBlock: _createBlock, createCommentVNode: _createCommentVNode, createTextVNode: _createTextVNode, Fragment: _Fragment, renderList: _renderList, createVNode: _createVNode } = Vue +"const { toDisplayString: _toDisplayString, openBlock: _openBlock, createElementBlock: _createElementBlock, createCommentVNode: _createCommentVNode, createTextVNode: _createTextVNode, Fragment: _Fragment, renderList: _renderList, createElementVNode: _createElementVNode, normalizeClass: _normalizeClass } = Vue return function render(_ctx, _cache) { - return (_openBlock(), _createBlock(\\"div\\", { + return (_openBlock(), _createElementBlock(\\"div\\", { id: \\"foo\\", - class: _ctx.bar.baz + class: _normalizeClass(_ctx.bar.baz) }, [ _createTextVNode(_toDisplayString(_ctx.world.burn()) + \\" \\", 1 /* TEXT */), (_ctx.ok) - ? (_openBlock(), _createBlock(\\"div\\", { key: 0 }, \\"yes\\")) - : (_openBlock(), _createBlock(_Fragment, { key: 1 }, [ + ? (_openBlock(), _createElementBlock(\\"div\\", { key: 0 }, \\"yes\\")) + : (_openBlock(), _createElementBlock(_Fragment, { key: 1 }, [ _createTextVNode(\\"no\\") ], 2112 /* STABLE_FRAGMENT, DEV_ROOT_FRAGMENT */)), - (_openBlock(true), _createBlock(_Fragment, null, _renderList(_ctx.list, (value, index) => { - return (_openBlock(), _createBlock(\\"div\\", null, [ - _createVNode(\\"span\\", null, _toDisplayString(value + index), 1 /* TEXT */) + (_openBlock(true), _createElementBlock(_Fragment, null, _renderList(_ctx.list, (value, index) => { + return (_openBlock(), _createElementBlock(\\"div\\", null, [ + _createElementVNode(\\"span\\", null, _toDisplayString(value + index), 1 /* TEXT */) ])) }), 256 /* UNKEYED_FRAGMENT */)) ], 2 /* CLASS */)) @@ -51,22 +51,22 @@ return function render(_ctx, _cache) { `; exports[`compiler: integration tests module mode 1`] = ` -"import { toDisplayString as _toDisplayString, openBlock as _openBlock, createBlock as _createBlock, createCommentVNode as _createCommentVNode, createTextVNode as _createTextVNode, Fragment as _Fragment, renderList as _renderList, createVNode as _createVNode } from \\"vue\\" +"import { toDisplayString as _toDisplayString, openBlock as _openBlock, createElementBlock as _createElementBlock, createCommentVNode as _createCommentVNode, createTextVNode as _createTextVNode, Fragment as _Fragment, renderList as _renderList, createElementVNode as _createElementVNode, normalizeClass as _normalizeClass } from \\"vue\\" export function render(_ctx, _cache) { - return (_openBlock(), _createBlock(\\"div\\", { + return (_openBlock(), _createElementBlock(\\"div\\", { id: \\"foo\\", - class: _ctx.bar.baz + class: _normalizeClass(_ctx.bar.baz) }, [ _createTextVNode(_toDisplayString(_ctx.world.burn()) + \\" \\", 1 /* TEXT */), (_ctx.ok) - ? (_openBlock(), _createBlock(\\"div\\", { key: 0 }, \\"yes\\")) - : (_openBlock(), _createBlock(_Fragment, { key: 1 }, [ + ? (_openBlock(), _createElementBlock(\\"div\\", { key: 0 }, \\"yes\\")) + : (_openBlock(), _createElementBlock(_Fragment, { key: 1 }, [ _createTextVNode(\\"no\\") ], 2112 /* STABLE_FRAGMENT, DEV_ROOT_FRAGMENT */)), - (_openBlock(true), _createBlock(_Fragment, null, _renderList(_ctx.list, (value, index) => { - return (_openBlock(), _createBlock(\\"div\\", null, [ - _createVNode(\\"span\\", null, _toDisplayString(value + index), 1 /* TEXT */) + (_openBlock(true), _createElementBlock(_Fragment, null, _renderList(_ctx.list, (value, index) => { + return (_openBlock(), _createElementBlock(\\"div\\", null, [ + _createElementVNode(\\"span\\", null, _toDisplayString(value + index), 1 /* TEXT */) ])) }), 256 /* UNKEYED_FRAGMENT */)) ], 2 /* CLASS */)) diff --git a/packages/compiler-core/__tests__/__snapshots__/scopeId.spec.ts.snap b/packages/compiler-core/__tests__/__snapshots__/scopeId.spec.ts.snap index aa74c6c43d1..d03efd45c6d 100644 --- a/packages/compiler-core/__tests__/__snapshots__/scopeId.spec.ts.snap +++ b/packages/compiler-core/__tests__/__snapshots__/scopeId.spec.ts.snap @@ -1,16 +1,16 @@ // Jest Snapshot v1, https://goo.gl/fbAQLP exports[`scopeId compiler support should push scopeId for hoisted nodes 1`] = ` -"import { createVNode as _createVNode, toDisplayString as _toDisplayString, createTextVNode as _createTextVNode, openBlock as _openBlock, createBlock as _createBlock, withScopeId as _withScopeId, pushScopeId as _pushScopeId, popScopeId as _popScopeId } from \\"vue\\" +"import { createElementVNode as _createElementVNode, toDisplayString as _toDisplayString, createTextVNode as _createTextVNode, openBlock as _openBlock, createElementBlock as _createElementBlock, withScopeId as _withScopeId, pushScopeId as _pushScopeId, popScopeId as _popScopeId } from \\"vue\\" const _withId = /*#__PURE__*/_withScopeId(\\"test\\") _pushScopeId(\\"test\\") -const _hoisted_1 = /*#__PURE__*/_createVNode(\\"div\\", null, \\"hello\\", -1 /* HOISTED */) -const _hoisted_2 = /*#__PURE__*/_createVNode(\\"div\\", null, \\"world\\", -1 /* HOISTED */) +const _hoisted_1 = /*#__PURE__*/_createElementVNode(\\"div\\", null, \\"hello\\", -1 /* HOISTED */) +const _hoisted_2 = /*#__PURE__*/_createElementVNode(\\"div\\", null, \\"world\\", -1 /* HOISTED */) _popScopeId() export const render = /*#__PURE__*/_withId((_ctx, _cache) => { - return (_openBlock(), _createBlock(\\"div\\", null, [ + return (_openBlock(), _createElementBlock(\\"div\\", null, [ _hoisted_1, _createTextVNode(_toDisplayString(_ctx.foo), 1 /* TEXT */), _hoisted_2 @@ -19,7 +19,7 @@ export const render = /*#__PURE__*/_withId((_ctx, _cache) => { `; exports[`scopeId compiler support should wrap default slot 1`] = ` -"import { createVNode as _createVNode, resolveComponent as _resolveComponent, withCtx as _withCtx, openBlock as _openBlock, createBlock as _createBlock, withScopeId as _withScopeId } from \\"vue\\" +"import { createElementVNode as _createElementVNode, resolveComponent as _resolveComponent, withCtx as _withCtx, openBlock as _openBlock, createBlock as _createBlock, withScopeId as _withScopeId } from \\"vue\\" const _withId = /*#__PURE__*/_withScopeId(\\"test\\") export const render = /*#__PURE__*/_withId((_ctx, _cache) => { @@ -27,7 +27,7 @@ export const render = /*#__PURE__*/_withId((_ctx, _cache) => { return (_openBlock(), _createBlock(_component_Child, null, { default: _withId(() => [ - _createVNode(\\"div\\") + _createElementVNode(\\"div\\") ]), _: 1 /* STABLE */ })) @@ -35,7 +35,7 @@ export const render = /*#__PURE__*/_withId((_ctx, _cache) => { `; exports[`scopeId compiler support should wrap dynamic slots 1`] = ` -"import { createVNode as _createVNode, resolveComponent as _resolveComponent, withCtx as _withCtx, renderList as _renderList, createSlots as _createSlots, openBlock as _openBlock, createBlock as _createBlock, withScopeId as _withScopeId } from \\"vue\\" +"import { createElementVNode as _createElementVNode, resolveComponent as _resolveComponent, withCtx as _withCtx, renderList as _renderList, createSlots as _createSlots, openBlock as _openBlock, createBlock as _createBlock, withScopeId as _withScopeId } from \\"vue\\" const _withId = /*#__PURE__*/_withScopeId(\\"test\\") export const render = /*#__PURE__*/_withId((_ctx, _cache) => { @@ -46,7 +46,7 @@ export const render = /*#__PURE__*/_withId((_ctx, _cache) => { ? { name: \\"foo\\", fn: _withId(() => [ - _createVNode(\\"div\\") + _createElementVNode(\\"div\\") ]) } : undefined, @@ -54,7 +54,7 @@ export const render = /*#__PURE__*/_withId((_ctx, _cache) => { return { name: i, fn: _withId(() => [ - _createVNode(\\"div\\") + _createElementVNode(\\"div\\") ]) } }) @@ -63,7 +63,7 @@ export const render = /*#__PURE__*/_withId((_ctx, _cache) => { `; exports[`scopeId compiler support should wrap named slots 1`] = ` -"import { toDisplayString as _toDisplayString, createTextVNode as _createTextVNode, createVNode as _createVNode, resolveComponent as _resolveComponent, withCtx as _withCtx, openBlock as _openBlock, createBlock as _createBlock, withScopeId as _withScopeId } from \\"vue\\" +"import { toDisplayString as _toDisplayString, createTextVNode as _createTextVNode, createElementVNode as _createElementVNode, resolveComponent as _resolveComponent, withCtx as _withCtx, openBlock as _openBlock, createBlock as _createBlock, withScopeId as _withScopeId } from \\"vue\\" const _withId = /*#__PURE__*/_withScopeId(\\"test\\") export const render = /*#__PURE__*/_withId((_ctx, _cache) => { @@ -74,7 +74,7 @@ export const render = /*#__PURE__*/_withId((_ctx, _cache) => { _createTextVNode(_toDisplayString(msg), 1 /* TEXT */) ]), bar: _withId(() => [ - _createVNode(\\"div\\") + _createElementVNode(\\"div\\") ]), _: 1 /* STABLE */ })) diff --git a/packages/compiler-core/__tests__/codegen.spec.ts b/packages/compiler-core/__tests__/codegen.spec.ts index 75001f94aff..61908a9105b 100644 --- a/packages/compiler-core/__tests__/codegen.spec.ts +++ b/packages/compiler-core/__tests__/codegen.spec.ts @@ -31,7 +31,8 @@ import { RESOLVE_COMPONENT, CREATE_COMMENT, FRAGMENT, - RENDER_LIST + RENDER_LIST, + CREATE_ELEMENT_VNODE } from '../src/runtimeHelpers' import { createElementWithCodegen, genFlagText } from './testUtils' import { PatchFlags } from '@vue/shared' @@ -395,12 +396,12 @@ describe('compiler: codegen', () => { }) ) expect(code).toMatch(` - return _${helperNameMap[CREATE_VNODE]}("div", { + return _${helperNameMap[CREATE_ELEMENT_VNODE]}("div", { id: "foo", [prop]: bar, [foo + bar]: bar }, [ - _${helperNameMap[CREATE_VNODE]}("p", { "some-key": "foo" }) + _${helperNameMap[CREATE_ELEMENT_VNODE]}("p", { "some-key": "foo" }) ], ${PatchFlags.FULL_PROPS})`) expect(code).toMatchSnapshot() }) @@ -658,11 +659,11 @@ describe('compiler: codegen', () => { test('tag only', () => { expect(genCode(createVNodeCall(null, `"div"`))).toMatchInlineSnapshot(` - "return _createVNode(\\"div\\") + "return _createElementVNode(\\"div\\") " `) expect(genCode(createVNodeCall(null, FRAGMENT))).toMatchInlineSnapshot(` - "return _createVNode(_Fragment) + "return _createElementVNode(_Fragment) " `) }) @@ -670,7 +671,7 @@ describe('compiler: codegen', () => { test('with props', () => { expect(genCode(createVNodeCall(null, `"div"`, mockProps))) .toMatchInlineSnapshot(` - "return _createVNode(\\"div\\", { foo: \\"bar\\" }) + "return _createElementVNode(\\"div\\", { foo: \\"bar\\" }) " `) }) @@ -678,7 +679,7 @@ describe('compiler: codegen', () => { test('with children, no props', () => { expect(genCode(createVNodeCall(null, `"div"`, undefined, mockChildren))) .toMatchInlineSnapshot(` - "return _createVNode(\\"div\\", null, children) + "return _createElementVNode(\\"div\\", null, children) " `) }) @@ -686,7 +687,7 @@ describe('compiler: codegen', () => { test('with children + props', () => { expect(genCode(createVNodeCall(null, `"div"`, mockProps, mockChildren))) .toMatchInlineSnapshot(` - "return _createVNode(\\"div\\", { foo: \\"bar\\" }, children) + "return _createElementVNode(\\"div\\", { foo: \\"bar\\" }, children) " `) }) @@ -694,7 +695,7 @@ describe('compiler: codegen', () => { test('with patchFlag and no children/props', () => { expect(genCode(createVNodeCall(null, `"div"`, undefined, undefined, '1'))) .toMatchInlineSnapshot(` - "return _createVNode(\\"div\\", null, null, 1) + "return _createElementVNode(\\"div\\", null, null, 1) " `) }) @@ -714,7 +715,7 @@ describe('compiler: codegen', () => { ) ) ).toMatchInlineSnapshot(` - "return (_openBlock(), _createBlock(\\"div\\", { foo: \\"bar\\" }, children)) + "return (_openBlock(), _createElementBlock(\\"div\\", { foo: \\"bar\\" }, children)) " `) }) @@ -735,7 +736,7 @@ describe('compiler: codegen', () => { ) ) ).toMatchInlineSnapshot(` - "return (_openBlock(true), _createBlock(\\"div\\", { foo: \\"bar\\" }, children)) + "return (_openBlock(true), _createElementBlock(\\"div\\", { foo: \\"bar\\" }, children)) " `) }) @@ -754,7 +755,7 @@ describe('compiler: codegen', () => { ) ) ).toMatchInlineSnapshot(` - "return _withDirectives(_createVNode(\\"div\\", { foo: \\"bar\\" }, children), [ + "return _withDirectives(_createElementVNode(\\"div\\", { foo: \\"bar\\" }, children), [ [foo, bar] ]) " @@ -776,7 +777,7 @@ describe('compiler: codegen', () => { ) ) ).toMatchInlineSnapshot(` - "return _withDirectives((_openBlock(), _createBlock(\\"div\\", { foo: \\"bar\\" }, children)), [ + "return _withDirectives((_openBlock(), _createElementBlock(\\"div\\", { foo: \\"bar\\" }, children)), [ [foo, bar] ]) " diff --git a/packages/compiler-core/__tests__/scopeId.spec.ts b/packages/compiler-core/__tests__/scopeId.spec.ts index 37ffb8893ca..a9545d86294 100644 --- a/packages/compiler-core/__tests__/scopeId.spec.ts +++ b/packages/compiler-core/__tests__/scopeId.spec.ts @@ -73,10 +73,10 @@ describe('scopeId compiler support', () => { expect(code).toMatch( [ `_pushScopeId("test")`, - `const _hoisted_1 = /*#__PURE__*/_createVNode("div", null, "hello", ${genFlagText( + `const _hoisted_1 = /*#__PURE__*/_createElementVNode("div", null, "hello", ${genFlagText( PatchFlags.HOISTED )})`, - `const _hoisted_2 = /*#__PURE__*/_createVNode("div", null, "world", ${genFlagText( + `const _hoisted_2 = /*#__PURE__*/_createElementVNode("div", null, "world", ${genFlagText( PatchFlags.HOISTED )})`, `_popScopeId()` diff --git a/packages/compiler-core/__tests__/testUtils.ts b/packages/compiler-core/__tests__/testUtils.ts index 61d2d8d0fce..2761aba698a 100644 --- a/packages/compiler-core/__tests__/testUtils.ts +++ b/packages/compiler-core/__tests__/testUtils.ts @@ -6,7 +6,13 @@ import { ElementTypes, VNodeCall } from '../src' -import { isString, PatchFlags, PatchFlagNames, isArray } from '@vue/shared' +import { + isString, + PatchFlags, + PatchFlagNames, + isArray, + ShapeFlags +} from '@vue/shared' const leadingBracketRE = /^\[/ const bracketsRE = /^\[|\]$/g @@ -63,19 +69,25 @@ export function createElementWithCodegen( directives: undefined, isBlock: false, disableTracking: false, + isComponent: false, + shapeFlag: ShapeFlags.ELEMENT + ``, loc: locStub } } } -export function genFlagText(flag: PatchFlags | PatchFlags[]) { +type Flags = PatchFlags | ShapeFlags +export function genFlagText( + flag: Flags | Flags[], + names: { [k: number]: string } = PatchFlagNames +) { if (isArray(flag)) { let f = 0 flag.forEach(ff => { f |= ff }) - return `${f} /* ${flag.map(f => PatchFlagNames[f]).join(', ')} */` + return `${f} /* ${flag.map(f => names[f]).join(', ')} */` } else { - return `${flag} /* ${PatchFlagNames[flag]} */` + return `${flag} /* ${names[flag]} */` } } diff --git a/packages/compiler-core/__tests__/transforms/__snapshots__/hoistStatic.spec.ts.snap b/packages/compiler-core/__tests__/transforms/__snapshots__/hoistStatic.spec.ts.snap index 022b243e367..430aa254e52 100644 --- a/packages/compiler-core/__tests__/transforms/__snapshots__/hoistStatic.spec.ts.snap +++ b/packages/compiler-core/__tests__/transforms/__snapshots__/hoistStatic.spec.ts.snap @@ -2,15 +2,15 @@ exports[`compiler: hoistStatic transform hoist element with static key 1`] = ` "const _Vue = Vue -const { createVNode: _createVNode } = _Vue +const { createElementVNode: _createElementVNode } = _Vue -const _hoisted_1 = /*#__PURE__*/_createVNode(\\"div\\", { key: \\"foo\\" }, null, -1 /* HOISTED */) +const _hoisted_1 = /*#__PURE__*/_createElementVNode(\\"div\\", { key: \\"foo\\" }, null, -1 /* HOISTED */) return function render(_ctx, _cache) { with (_ctx) { - const { createVNode: _createVNode, openBlock: _openBlock, createBlock: _createBlock } = _Vue + const { createElementVNode: _createElementVNode, openBlock: _openBlock, createElementBlock: _createElementBlock } = _Vue - return (_openBlock(), _createBlock(\\"div\\", null, [ + return (_openBlock(), _createElementBlock(\\"div\\", null, [ _hoisted_1 ])) } @@ -19,18 +19,18 @@ return function render(_ctx, _cache) { exports[`compiler: hoistStatic transform hoist nested static tree 1`] = ` "const _Vue = Vue -const { createVNode: _createVNode } = _Vue +const { createElementVNode: _createElementVNode } = _Vue -const _hoisted_1 = /*#__PURE__*/_createVNode(\\"p\\", null, [ - /*#__PURE__*/_createVNode(\\"span\\"), - /*#__PURE__*/_createVNode(\\"span\\") +const _hoisted_1 = /*#__PURE__*/_createElementVNode(\\"p\\", null, [ + /*#__PURE__*/_createElementVNode(\\"span\\"), + /*#__PURE__*/_createElementVNode(\\"span\\") ], -1 /* HOISTED */) return function render(_ctx, _cache) { with (_ctx) { - const { createVNode: _createVNode, openBlock: _openBlock, createBlock: _createBlock } = _Vue + const { createElementVNode: _createElementVNode, openBlock: _openBlock, createElementBlock: _createElementBlock } = _Vue - return (_openBlock(), _createBlock(\\"div\\", null, [ + return (_openBlock(), _createElementBlock(\\"div\\", null, [ _hoisted_1 ])) } @@ -39,17 +39,17 @@ return function render(_ctx, _cache) { exports[`compiler: hoistStatic transform hoist nested static tree with comments 1`] = ` "const _Vue = Vue -const { createVNode: _createVNode, createCommentVNode: _createCommentVNode } = _Vue +const { createElementVNode: _createElementVNode, createCommentVNode: _createCommentVNode } = _Vue -const _hoisted_1 = /*#__PURE__*/_createVNode(\\"div\\", null, [ +const _hoisted_1 = /*#__PURE__*/_createElementVNode(\\"div\\", null, [ /*#__PURE__*/_createCommentVNode(\\"comment\\") ], -1 /* HOISTED */) return function render(_ctx, _cache) { with (_ctx) { - const { createCommentVNode: _createCommentVNode, createVNode: _createVNode, openBlock: _openBlock, createBlock: _createBlock } = _Vue + const { createCommentVNode: _createCommentVNode, createElementVNode: _createElementVNode, openBlock: _openBlock, createElementBlock: _createElementBlock } = _Vue - return (_openBlock(), _createBlock(\\"div\\", null, [ + return (_openBlock(), _createElementBlock(\\"div\\", null, [ _hoisted_1 ])) } @@ -58,16 +58,16 @@ return function render(_ctx, _cache) { exports[`compiler: hoistStatic transform hoist siblings with common non-hoistable parent 1`] = ` "const _Vue = Vue -const { createVNode: _createVNode } = _Vue +const { createElementVNode: _createElementVNode } = _Vue -const _hoisted_1 = /*#__PURE__*/_createVNode(\\"span\\", null, null, -1 /* HOISTED */) -const _hoisted_2 = /*#__PURE__*/_createVNode(\\"div\\", null, null, -1 /* HOISTED */) +const _hoisted_1 = /*#__PURE__*/_createElementVNode(\\"span\\", null, null, -1 /* HOISTED */) +const _hoisted_2 = /*#__PURE__*/_createElementVNode(\\"div\\", null, null, -1 /* HOISTED */) return function render(_ctx, _cache) { with (_ctx) { - const { createVNode: _createVNode, openBlock: _openBlock, createBlock: _createBlock } = _Vue + const { createElementVNode: _createElementVNode, openBlock: _openBlock, createElementBlock: _createElementBlock } = _Vue - return (_openBlock(), _createBlock(\\"div\\", null, [ + return (_openBlock(), _createElementBlock(\\"div\\", null, [ _hoisted_1, _hoisted_2 ])) @@ -77,15 +77,15 @@ return function render(_ctx, _cache) { exports[`compiler: hoistStatic transform hoist simple element 1`] = ` "const _Vue = Vue -const { createVNode: _createVNode } = _Vue +const { createElementVNode: _createElementVNode } = _Vue -const _hoisted_1 = /*#__PURE__*/_createVNode(\\"span\\", { class: \\"inline\\" }, \\"hello\\", -1 /* HOISTED */) +const _hoisted_1 = /*#__PURE__*/_createElementVNode(\\"span\\", { class: \\"inline\\" }, \\"hello\\", -1 /* HOISTED */) return function render(_ctx, _cache) { with (_ctx) { - const { createVNode: _createVNode, openBlock: _openBlock, createBlock: _createBlock } = _Vue + const { createElementVNode: _createElementVNode, openBlock: _openBlock, createElementBlock: _createElementBlock } = _Vue - return (_openBlock(), _createBlock(\\"div\\", null, [ + return (_openBlock(), _createElementBlock(\\"div\\", null, [ _hoisted_1 ])) } @@ -94,18 +94,18 @@ return function render(_ctx, _cache) { exports[`compiler: hoistStatic transform hoist static props for elements with directives 1`] = ` "const _Vue = Vue -const { createVNode: _createVNode } = _Vue +const { createElementVNode: _createElementVNode } = _Vue const _hoisted_1 = { id: \\"foo\\" } return function render(_ctx, _cache) { with (_ctx) { - const { resolveDirective: _resolveDirective, createVNode: _createVNode, withDirectives: _withDirectives, openBlock: _openBlock, createBlock: _createBlock } = _Vue + const { resolveDirective: _resolveDirective, createElementVNode: _createElementVNode, withDirectives: _withDirectives, openBlock: _openBlock, createElementBlock: _createElementBlock } = _Vue const _directive_foo = _resolveDirective(\\"foo\\") - return (_openBlock(), _createBlock(\\"div\\", null, [ - _withDirectives(_createVNode(\\"div\\", _hoisted_1, null, 512 /* NEED_PATCH */), [ + return (_openBlock(), _createElementBlock(\\"div\\", null, [ + _withDirectives(_createElementVNode(\\"div\\", _hoisted_1, null, 512 /* NEED_PATCH */), [ [_directive_foo] ]) ])) @@ -115,16 +115,16 @@ return function render(_ctx, _cache) { exports[`compiler: hoistStatic transform hoist static props for elements with dynamic text children 1`] = ` "const _Vue = Vue -const { createVNode: _createVNode } = _Vue +const { createElementVNode: _createElementVNode } = _Vue const _hoisted_1 = { id: \\"foo\\" } return function render(_ctx, _cache) { with (_ctx) { - const { toDisplayString: _toDisplayString, createVNode: _createVNode, openBlock: _openBlock, createBlock: _createBlock } = _Vue + const { toDisplayString: _toDisplayString, createElementVNode: _createElementVNode, openBlock: _openBlock, createElementBlock: _createElementBlock } = _Vue - return (_openBlock(), _createBlock(\\"div\\", null, [ - _createVNode(\\"div\\", _hoisted_1, _toDisplayString(hello), 1 /* TEXT */) + return (_openBlock(), _createElementBlock(\\"div\\", null, [ + _createElementVNode(\\"div\\", _hoisted_1, _toDisplayString(hello), 1 /* TEXT */) ])) } }" @@ -132,18 +132,18 @@ return function render(_ctx, _cache) { exports[`compiler: hoistStatic transform hoist static props for elements with unhoistable children 1`] = ` "const _Vue = Vue -const { createVNode: _createVNode } = _Vue +const { createVNode: _createVNode, createElementVNode: _createElementVNode } = _Vue const _hoisted_1 = { id: \\"foo\\" } return function render(_ctx, _cache) { with (_ctx) { - const { resolveComponent: _resolveComponent, createVNode: _createVNode, openBlock: _openBlock, createBlock: _createBlock } = _Vue + const { resolveComponent: _resolveComponent, createVNode: _createVNode, createElementVNode: _createElementVNode, openBlock: _openBlock, createElementBlock: _createElementBlock } = _Vue const _component_Comp = _resolveComponent(\\"Comp\\") - return (_openBlock(), _createBlock(\\"div\\", null, [ - _createVNode(\\"div\\", _hoisted_1, [ + return (_openBlock(), _createElementBlock(\\"div\\", null, [ + _createElementVNode(\\"div\\", _hoisted_1, [ _createVNode(_component_Comp) ]) ])) @@ -153,16 +153,18 @@ return function render(_ctx, _cache) { exports[`compiler: hoistStatic transform prefixIdentifiers hoist class with static object value 1`] = ` "const _Vue = Vue -const { createVNode: _createVNode } = _Vue +const { createElementVNode: _createElementVNode } = _Vue -const _hoisted_1 = { class: { foo: true } } +const _hoisted_1 = { + class: /*#__PURE__*/_normalizeClass({ foo: true }) +} return function render(_ctx, _cache) { with (_ctx) { - const { toDisplayString: _toDisplayString, createVNode: _createVNode, openBlock: _openBlock, createBlock: _createBlock } = _Vue + const { toDisplayString: _toDisplayString, normalizeClass: _normalizeClass, createElementVNode: _createElementVNode, openBlock: _openBlock, createElementBlock: _createElementBlock } = _Vue - return (_openBlock(), _createBlock(\\"div\\", null, [ - _createVNode(\\"span\\", _hoisted_1, _toDisplayString(_ctx.bar), 1 /* TEXT */) + return (_openBlock(), _createElementBlock(\\"div\\", null, [ + _createElementVNode(\\"span\\", _hoisted_1, _toDisplayString(_ctx.bar), 1 /* TEXT */) ])) } }" @@ -170,15 +172,15 @@ return function render(_ctx, _cache) { exports[`compiler: hoistStatic transform prefixIdentifiers hoist nested static tree with static interpolation 1`] = ` "const _Vue = Vue -const { createVNode: _createVNode } = _Vue +const { createElementVNode: _createElementVNode } = _Vue -const _hoisted_1 = /*#__PURE__*/_createVNode(\\"span\\", null, \\"foo \\" + /*#__PURE__*/_toDisplayString(1) + \\" \\" + /*#__PURE__*/_toDisplayString(true), -1 /* HOISTED */) +const _hoisted_1 = /*#__PURE__*/_createElementVNode(\\"span\\", null, \\"foo \\" + /*#__PURE__*/_toDisplayString(1) + \\" \\" + /*#__PURE__*/_toDisplayString(true), -1 /* HOISTED */) return function render(_ctx, _cache) { with (_ctx) { - const { toDisplayString: _toDisplayString, createVNode: _createVNode, openBlock: _openBlock, createBlock: _createBlock } = _Vue + const { toDisplayString: _toDisplayString, createElementVNode: _createElementVNode, openBlock: _openBlock, createElementBlock: _createElementBlock } = _Vue - return (_openBlock(), _createBlock(\\"div\\", null, [ + return (_openBlock(), _createElementBlock(\\"div\\", null, [ _hoisted_1 ])) } @@ -187,15 +189,15 @@ return function render(_ctx, _cache) { exports[`compiler: hoistStatic transform prefixIdentifiers hoist nested static tree with static prop value 1`] = ` "const _Vue = Vue -const { createVNode: _createVNode } = _Vue +const { createElementVNode: _createElementVNode } = _Vue -const _hoisted_1 = /*#__PURE__*/_createVNode(\\"span\\", { foo: 0 }, /*#__PURE__*/_toDisplayString(1), -1 /* HOISTED */) +const _hoisted_1 = /*#__PURE__*/_createElementVNode(\\"span\\", { foo: 0 }, /*#__PURE__*/_toDisplayString(1), -1 /* HOISTED */) return function render(_ctx, _cache) { with (_ctx) { - const { toDisplayString: _toDisplayString, createVNode: _createVNode, openBlock: _openBlock, createBlock: _createBlock } = _Vue + const { toDisplayString: _toDisplayString, createElementVNode: _createElementVNode, openBlock: _openBlock, createElementBlock: _createElementBlock } = _Vue - return (_openBlock(), _createBlock(\\"div\\", null, [ + return (_openBlock(), _createElementBlock(\\"div\\", null, [ _hoisted_1 ])) } @@ -203,12 +205,12 @@ return function render(_ctx, _cache) { `; exports[`compiler: hoistStatic transform prefixIdentifiers should NOT hoist elements with cached handlers 1`] = ` -"import { createVNode as _createVNode, openBlock as _openBlock, createBlock as _createBlock } from \\"vue\\" +"import { createElementVNode as _createElementVNode, openBlock as _openBlock, createElementBlock as _createElementBlock } from \\"vue\\" export function render(_ctx, _cache) { - return (_openBlock(), _createBlock(\\"div\\", null, [ - _createVNode(\\"div\\", null, [ - _createVNode(\\"div\\", { + return (_openBlock(), _createElementBlock(\\"div\\", null, [ + _createElementVNode(\\"div\\", null, [ + _createElementVNode(\\"div\\", { onClick: _cache[1] || (_cache[1] = (...args) => (_ctx.foo && _ctx.foo(...args))) }) ]) @@ -221,12 +223,12 @@ exports[`compiler: hoistStatic transform prefixIdentifiers should NOT hoist expr return function render(_ctx, _cache) { with (_ctx) { - const { renderList: _renderList, Fragment: _Fragment, openBlock: _openBlock, createBlock: _createBlock, toDisplayString: _toDisplayString, createVNode: _createVNode } = _Vue + const { renderList: _renderList, Fragment: _Fragment, openBlock: _openBlock, createElementBlock: _createElementBlock, toDisplayString: _toDisplayString, createElementVNode: _createElementVNode } = _Vue - return (_openBlock(), _createBlock(\\"div\\", null, [ - (_openBlock(true), _createBlock(_Fragment, null, _renderList(_ctx.list, (o) => { - return (_openBlock(), _createBlock(\\"p\\", null, [ - _createVNode(\\"span\\", null, _toDisplayString(o + 'foo'), 1 /* TEXT */) + return (_openBlock(), _createElementBlock(\\"div\\", null, [ + (_openBlock(true), _createElementBlock(_Fragment, null, _renderList(_ctx.list, (o) => { + return (_openBlock(), _createElementBlock(\\"p\\", null, [ + _createElementVNode(\\"span\\", null, _toDisplayString(o + 'foo'), 1 /* TEXT */) ])) }), 256 /* UNKEYED_FRAGMENT */)) ])) @@ -258,12 +260,12 @@ exports[`compiler: hoistStatic transform prefixIdentifiers should NOT hoist expr return function render(_ctx, _cache) { with (_ctx) { - const { renderList: _renderList, Fragment: _Fragment, openBlock: _openBlock, createBlock: _createBlock, toDisplayString: _toDisplayString, createVNode: _createVNode } = _Vue + const { renderList: _renderList, Fragment: _Fragment, openBlock: _openBlock, createElementBlock: _createElementBlock, toDisplayString: _toDisplayString, createElementVNode: _createElementVNode } = _Vue - return (_openBlock(), _createBlock(\\"div\\", null, [ - (_openBlock(true), _createBlock(_Fragment, null, _renderList(_ctx.list, (o) => { - return (_openBlock(), _createBlock(\\"p\\", null, [ - _createVNode(\\"span\\", null, _toDisplayString(o), 1 /* TEXT */) + return (_openBlock(), _createElementBlock(\\"div\\", null, [ + (_openBlock(true), _createElementBlock(_Fragment, null, _renderList(_ctx.list, (o) => { + return (_openBlock(), _createElementBlock(\\"p\\", null, [ + _createElementVNode(\\"span\\", null, _toDisplayString(o), 1 /* TEXT */) ])) }), 256 /* UNKEYED_FRAGMENT */)) ])) @@ -276,11 +278,11 @@ exports[`compiler: hoistStatic transform prefixIdentifiers should NOT hoist keye return function render(_ctx, _cache) { with (_ctx) { - const { renderList: _renderList, Fragment: _Fragment, openBlock: _openBlock, createBlock: _createBlock } = _Vue + const { renderList: _renderList, Fragment: _Fragment, openBlock: _openBlock, createElementBlock: _createElementBlock } = _Vue - return (_openBlock(), _createBlock(\\"div\\", null, [ - (_openBlock(true), _createBlock(_Fragment, null, _renderList(items, (item) => { - return (_openBlock(), _createBlock(\\"span\\", { key: item })) + return (_openBlock(), _createElementBlock(\\"div\\", null, [ + (_openBlock(true), _createElementBlock(_Fragment, null, _renderList(items, (item) => { + return (_openBlock(), _createElementBlock(\\"span\\", { key: item })) }), 128 /* KEYED_FRAGMENT */)) ])) } @@ -292,11 +294,11 @@ exports[`compiler: hoistStatic transform should NOT hoist components 1`] = ` return function render(_ctx, _cache) { with (_ctx) { - const { resolveComponent: _resolveComponent, createVNode: _createVNode, openBlock: _openBlock, createBlock: _createBlock } = _Vue + const { resolveComponent: _resolveComponent, createVNode: _createVNode, openBlock: _openBlock, createElementBlock: _createElementBlock } = _Vue const _component_Comp = _resolveComponent(\\"Comp\\") - return (_openBlock(), _createBlock(\\"div\\", null, [ + return (_openBlock(), _createElementBlock(\\"div\\", null, [ _createVNode(_component_Comp) ])) } @@ -308,10 +310,10 @@ exports[`compiler: hoistStatic transform should NOT hoist element with dynamic k return function render(_ctx, _cache) { with (_ctx) { - const { openBlock: _openBlock, createBlock: _createBlock } = _Vue + const { openBlock: _openBlock, createElementBlock: _createElementBlock } = _Vue - return (_openBlock(), _createBlock(\\"div\\", null, [ - (_openBlock(), _createBlock(\\"div\\", { key: foo })) + return (_openBlock(), _createElementBlock(\\"div\\", null, [ + (_openBlock(), _createElementBlock(\\"div\\", { key: foo })) ])) } }" @@ -322,10 +324,10 @@ exports[`compiler: hoistStatic transform should NOT hoist element with dynamic p return function render(_ctx, _cache) { with (_ctx) { - const { createVNode: _createVNode, openBlock: _openBlock, createBlock: _createBlock } = _Vue + const { createElementVNode: _createElementVNode, openBlock: _openBlock, createElementBlock: _createElementBlock } = _Vue - return (_openBlock(), _createBlock(\\"div\\", null, [ - _createVNode(\\"div\\", { id: foo }, null, 8 /* PROPS */, [\\"id\\"]) + return (_openBlock(), _createElementBlock(\\"div\\", null, [ + _createElementVNode(\\"div\\", { id: foo }, null, 8 /* PROPS */, [\\"id\\"]) ])) } }" @@ -336,10 +338,10 @@ exports[`compiler: hoistStatic transform should NOT hoist element with dynamic r return function render(_ctx, _cache) { with (_ctx) { - const { createVNode: _createVNode, openBlock: _openBlock, createBlock: _createBlock } = _Vue + const { createElementVNode: _createElementVNode, openBlock: _openBlock, createElementBlock: _createElementBlock } = _Vue - return (_openBlock(), _createBlock(\\"div\\", null, [ - _createVNode(\\"div\\", { ref: foo }, null, 512 /* NEED_PATCH */) + return (_openBlock(), _createElementBlock(\\"div\\", null, [ + _createElementVNode(\\"div\\", { ref: foo }, null, 512 /* NEED_PATCH */) ])) } }" @@ -350,27 +352,27 @@ exports[`compiler: hoistStatic transform should NOT hoist root node 1`] = ` return function render(_ctx, _cache) { with (_ctx) { - const { openBlock: _openBlock, createBlock: _createBlock } = _Vue + const { openBlock: _openBlock, createElementBlock: _createElementBlock } = _Vue - return (_openBlock(), _createBlock(\\"div\\")) + return (_openBlock(), _createElementBlock(\\"div\\")) } }" `; exports[`compiler: hoistStatic transform should hoist v-for children if static 1`] = ` "const _Vue = Vue -const { createVNode: _createVNode } = _Vue +const { createElementVNode: _createElementVNode } = _Vue const _hoisted_1 = { id: \\"foo\\" } -const _hoisted_2 = /*#__PURE__*/_createVNode(\\"span\\", null, null, -1 /* HOISTED */) +const _hoisted_2 = /*#__PURE__*/_createElementVNode(\\"span\\", null, null, -1 /* HOISTED */) return function render(_ctx, _cache) { with (_ctx) { - const { renderList: _renderList, Fragment: _Fragment, openBlock: _openBlock, createBlock: _createBlock, createVNode: _createVNode } = _Vue + const { renderList: _renderList, Fragment: _Fragment, openBlock: _openBlock, createElementBlock: _createElementBlock, createElementVNode: _createElementVNode } = _Vue - return (_openBlock(), _createBlock(\\"div\\", null, [ - (_openBlock(true), _createBlock(_Fragment, null, _renderList(list, (i) => { - return (_openBlock(), _createBlock(\\"div\\", _hoisted_1, [ + return (_openBlock(), _createElementBlock(\\"div\\", null, [ + (_openBlock(true), _createElementBlock(_Fragment, null, _renderList(list, (i) => { + return (_openBlock(), _createElementBlock(\\"div\\", _hoisted_1, [ _hoisted_2 ])) }), 256 /* UNKEYED_FRAGMENT */)) @@ -381,21 +383,21 @@ return function render(_ctx, _cache) { exports[`compiler: hoistStatic transform should hoist v-if props/children if static 1`] = ` "const _Vue = Vue -const { createVNode: _createVNode, createCommentVNode: _createCommentVNode } = _Vue +const { createElementVNode: _createElementVNode, createCommentVNode: _createCommentVNode } = _Vue const _hoisted_1 = { key: 0, id: \\"foo\\" } -const _hoisted_2 = /*#__PURE__*/_createVNode(\\"span\\", null, null, -1 /* HOISTED */) +const _hoisted_2 = /*#__PURE__*/_createElementVNode(\\"span\\", null, null, -1 /* HOISTED */) return function render(_ctx, _cache) { with (_ctx) { - const { createVNode: _createVNode, openBlock: _openBlock, createBlock: _createBlock, createCommentVNode: _createCommentVNode } = _Vue + const { createElementVNode: _createElementVNode, openBlock: _openBlock, createElementBlock: _createElementBlock, createCommentVNode: _createCommentVNode } = _Vue - return (_openBlock(), _createBlock(\\"div\\", null, [ + return (_openBlock(), _createElementBlock(\\"div\\", null, [ ok - ? (_openBlock(), _createBlock(\\"div\\", _hoisted_1, [ + ? (_openBlock(), _createElementBlock(\\"div\\", _hoisted_1, [ _hoisted_2 ])) : _createCommentVNode(\\"v-if\\", true) diff --git a/packages/compiler-core/__tests__/transforms/__snapshots__/transformExpressions.spec.ts.snap b/packages/compiler-core/__tests__/transforms/__snapshots__/transformExpressions.spec.ts.snap index 165df1e1ae8..93c4277ffa3 100644 --- a/packages/compiler-core/__tests__/transforms/__snapshots__/transformExpressions.spec.ts.snap +++ b/packages/compiler-core/__tests__/transforms/__snapshots__/transformExpressions.spec.ts.snap @@ -2,14 +2,14 @@ exports[`compiler: expression transform bindingMetadata inline mode 1`] = ` "(_ctx, _cache) => { - return (_openBlock(), _createBlock(\\"div\\", null, _toDisplayString(__props.props) + \\" \\" + _toDisplayString(_unref(setup)) + \\" \\" + _toDisplayString(setupConst) + \\" \\" + _toDisplayString(_ctx.data) + \\" \\" + _toDisplayString(_ctx.options), 1 /* TEXT */)) + return (_openBlock(), _createElementBlock(\\"div\\", null, _toDisplayString(__props.props) + \\" \\" + _toDisplayString(_unref(setup)) + \\" \\" + _toDisplayString(setupConst) + \\" \\" + _toDisplayString(_ctx.data) + \\" \\" + _toDisplayString(_ctx.options), 1 /* TEXT */)) }" `; exports[`compiler: expression transform bindingMetadata non-inline mode 1`] = ` -"const { toDisplayString: _toDisplayString, openBlock: _openBlock, createBlock: _createBlock } = Vue +"const { toDisplayString: _toDisplayString, openBlock: _openBlock, createElementBlock: _createElementBlock } = Vue return function render(_ctx, _cache, $props, $setup, $data, $options) { - return (_openBlock(), _createBlock(\\"div\\", null, _toDisplayString($props.props) + \\" \\" + _toDisplayString($setup.setup) + \\" \\" + _toDisplayString($data.data) + \\" \\" + _toDisplayString($options.options), 1 /* TEXT */)) + return (_openBlock(), _createElementBlock(\\"div\\", null, _toDisplayString($props.props) + \\" \\" + _toDisplayString($setup.setup) + \\" \\" + _toDisplayString($data.data) + \\" \\" + _toDisplayString($options.options), 1 /* TEXT */)) }" `; diff --git a/packages/compiler-core/__tests__/transforms/__snapshots__/transformText.spec.ts.snap b/packages/compiler-core/__tests__/transforms/__snapshots__/transformText.spec.ts.snap index 07dadbcdc64..ada1ac6f1ca 100644 --- a/packages/compiler-core/__tests__/transforms/__snapshots__/transformText.spec.ts.snap +++ b/packages/compiler-core/__tests__/transforms/__snapshots__/transformText.spec.ts.snap @@ -5,10 +5,10 @@ exports[`compiler: transform text