From: Anthony Fu Date: Thu, 16 May 2024 17:43:48 +0000 (+0200) Subject: test: update X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=43dd14eb274ddc9aac58875dc7051ec05e990262;p=thirdparty%2Fvuejs%2Fcore.git test: update Co-authored-by: sxzz Co-authored-by: Doctor-wu Co-authored-by: ShenQingchuan --- 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 b62789e335..0a253522c5 100644 --- a/packages/compiler-core/__tests__/transforms/__snapshots__/hoistStatic.spec.ts.snap +++ b/packages/compiler-core/__tests__/transforms/__snapshots__/hoistStatic.spec.ts.snap @@ -105,7 +105,7 @@ const _hoisted_1 = /*#__PURE__*/ _hoistLazy(() => ({ id: "foo" })) return function render(_ctx, _cache) { with (_ctx) { - const { resolveDirective: _resolveDirective, createElementVNode: _createElementVNode, withDirectives: _withDirectives, openBlock: _openBlock, createElementBlock: _createElementBlock } = _Vue + const { resolveDirective: _resolveDirective, createElementVNode: _createElementVNode, withDirectives: _withDirectives, hoistLazy: _hoistLazy, openBlock: _openBlock, createElementBlock: _createElementBlock } = _Vue const _directive_foo = _resolveDirective("foo") @@ -126,7 +126,7 @@ const _hoisted_1 = /*#__PURE__*/ _hoistLazy(() => ({ id: "foo" })) return function render(_ctx, _cache) { with (_ctx) { - const { toDisplayString: _toDisplayString, createElementVNode: _createElementVNode, openBlock: _openBlock, createElementBlock: _createElementBlock } = _Vue + const { toDisplayString: _toDisplayString, createElementVNode: _createElementVNode, hoistLazy: _hoistLazy, openBlock: _openBlock, createElementBlock: _createElementBlock } = _Vue return (_openBlock(), _createElementBlock("div", null, [ _createElementVNode("div", _hoisted_1(), _toDisplayString(hello), 1 /* TEXT */) @@ -143,7 +143,7 @@ const _hoisted_1 = /*#__PURE__*/ _hoistLazy(() => ({ id: "foo" })) return function render(_ctx, _cache) { with (_ctx) { - const { resolveComponent: _resolveComponent, createVNode: _createVNode, createElementVNode: _createElementVNode, openBlock: _openBlock, createElementBlock: _createElementBlock } = _Vue + const { resolveComponent: _resolveComponent, createVNode: _createVNode, createElementVNode: _createElementVNode, hoistLazy: _hoistLazy, openBlock: _openBlock, createElementBlock: _createElementBlock } = _Vue const _component_Comp = _resolveComponent("Comp") @@ -166,7 +166,7 @@ const _hoisted_1 = /*#__PURE__*/ _hoistLazy(() => ({ return function render(_ctx, _cache) { with (_ctx) { - const { toDisplayString: _toDisplayString, normalizeClass: _normalizeClass, createElementVNode: _createElementVNode, openBlock: _openBlock, createElementBlock: _createElementBlock } = _Vue + const { toDisplayString: _toDisplayString, normalizeClass: _normalizeClass, createElementVNode: _createElementVNode, hoistLazy: _hoistLazy, openBlock: _openBlock, createElementBlock: _createElementBlock } = _Vue return (_openBlock(), _createElementBlock("div", null, [ _createElementVNode("span", _hoisted_1(), _toDisplayString(_ctx.bar), 1 /* TEXT */) @@ -373,7 +373,7 @@ const _hoisted_1 = /*#__PURE__*/ _hoistLazy(() => (["id"])) return function render(_ctx, _cache) { with (_ctx) { - const { createElementVNode: _createElementVNode, openBlock: _openBlock, createElementBlock: _createElementBlock } = _Vue + const { createElementVNode: _createElementVNode, hoistLazy: _hoistLazy, openBlock: _openBlock, createElementBlock: _createElementBlock } = _Vue return (_openBlock(), _createElementBlock("div", null, [ _createElementVNode("div", { id: foo }, null, 8 /* PROPS */, _hoisted_1()) diff --git a/packages/compiler-core/src/transform.ts b/packages/compiler-core/src/transform.ts index 81b1626778..401ff78659 100644 --- a/packages/compiler-core/src/transform.ts +++ b/packages/compiler-core/src/transform.ts @@ -34,6 +34,7 @@ import { defaultOnError, defaultOnWarn } from './errors' import { CREATE_COMMENT, FRAGMENT, + HOIST_LAZY, TO_DISPLAY_STRING, helperNameMap, } from './runtimeHelpers' @@ -285,6 +286,7 @@ export function createTransformContext( } }, hoist(exp) { + context.helper(HOIST_LAZY) if (isString(exp)) exp = createSimpleExpression(exp) context.hoists.push(exp) const identifier = createSimpleExpression( diff --git a/packages/compiler-core/src/transforms/hoistStatic.ts b/packages/compiler-core/src/transforms/hoistStatic.ts index ab3a5d6db0..70a0468e51 100644 --- a/packages/compiler-core/src/transforms/hoistStatic.ts +++ b/packages/compiler-core/src/transforms/hoistStatic.ts @@ -21,7 +21,6 @@ import { PatchFlags, isArray, isString, isSymbol } from '@vue/shared' import { isSlotOutlet } from '../utils' import { GUARD_REACTIVE_PROPS, - HOIST_LAZY, NORMALIZE_CLASS, NORMALIZE_PROPS, NORMALIZE_STYLE, @@ -71,7 +70,6 @@ function walk( : getConstantType(child, context) if (constantType > ConstantTypes.NOT_CONSTANT) { if (constantType >= ConstantTypes.CAN_HOIST) { - context.helper(HOIST_LAZY) ;(child.codegenNode as VNodeCall).patchFlag = PatchFlags.HOISTED + (__DEV__ ? ` /* HOISTED */` : ``) child.codegenNode = context.hoist(child.codegenNode!) diff --git a/packages/compiler-sfc/__tests__/__snapshots__/templateTransformAssetUrl.spec.ts.snap b/packages/compiler-sfc/__tests__/__snapshots__/templateTransformAssetUrl.spec.ts.snap index 6328ed1971..7f430b2587 100644 --- a/packages/compiler-sfc/__tests__/__snapshots__/templateTransformAssetUrl.spec.ts.snap +++ b/packages/compiler-sfc/__tests__/__snapshots__/templateTransformAssetUrl.spec.ts.snap @@ -33,7 +33,7 @@ export function render(_ctx, _cache) { `; exports[`compiler sfc: transform asset url > support uri fragment 1`] = ` -"import { createElementVNode as _createElementVNode, hoistLazy as _hoistLazy, Fragment as _Fragment, openBlock as _openBlock, createElementBlock as _createElementBlock } from "vue" +"import { hoistLazy as _hoistLazy, createElementVNode as _createElementVNode, Fragment as _Fragment, openBlock as _openBlock, createElementBlock as _createElementBlock } from "vue" import _imports_0 from '@svg/file.svg' diff --git a/packages/compiler-sfc/__tests__/__snapshots__/templateTransformSrcset.spec.ts.snap b/packages/compiler-sfc/__tests__/__snapshots__/templateTransformSrcset.spec.ts.snap index 9b7689cd43..97ee39f481 100644 --- a/packages/compiler-sfc/__tests__/__snapshots__/templateTransformSrcset.spec.ts.snap +++ b/packages/compiler-sfc/__tests__/__snapshots__/templateTransformSrcset.spec.ts.snap @@ -1,7 +1,7 @@ // Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html exports[`compiler sfc: transform srcset > srcset w/ explicit base option 1`] = ` -"import { createElementVNode as _createElementVNode, hoistLazy as _hoistLazy, Fragment as _Fragment, openBlock as _openBlock, createElementBlock as _createElementBlock } from "vue" +"import { hoistLazy as _hoistLazy, createElementVNode as _createElementVNode, Fragment as _Fragment, openBlock as _openBlock, createElementBlock as _createElementBlock } from "vue" import _imports_0 from '@/logo.png'