diff --git a/packages/compiler-core/__tests__/transforms/transformElement.spec.ts b/packages/compiler-core/__tests__/transforms/transformElement.spec.ts index b72533ee..138fa100 100644 --- a/packages/compiler-core/__tests__/transforms/transformElement.spec.ts +++ b/packages/compiler-core/__tests__/transforms/transformElement.spec.ts @@ -936,7 +936,7 @@ describe('compiler: element transform', () => { expect(node.patchFlag).toBe(genFlagText(PatchFlags.NEED_PATCH)) }) - test('the binding exists (inline ref input)', () => { + test('script setup inline mode template ref (binding exists)', () => { const { node } = parseWithElementTransform(``, { inline: true, bindingMetadata: { @@ -949,31 +949,30 @@ describe('compiler: element transform', () => { { type: NodeTypes.JS_PROPERTY, key: { - type: NodeTypes.SIMPLE_EXPRESSION, + content: 'ref_key', + isStatic: true + }, + value: { + content: 'input', + isStatic: true + } + }, + { + type: NodeTypes.JS_PROPERTY, + key: { content: 'ref', isStatic: true }, value: { - type: NodeTypes.JS_FUNCTION_EXPRESSION, - params: ['_value', '_refs'], - body: { - type: NodeTypes.JS_BLOCK_STATEMENT, - body: [ - { - content: `_refs['input'] = _value` - }, - { - content: 'input.value = _value' - } - ] - } + content: 'input', + isStatic: false } } ] }) }) - test('the binding not exists (inline ref input)', () => { + test('script setup inline mode template ref (binding does not exist)', () => { const { node } = parseWithElementTransform(``, { inline: true }) @@ -983,96 +982,12 @@ describe('compiler: element transform', () => { { type: NodeTypes.JS_PROPERTY, key: { - type: NodeTypes.SIMPLE_EXPRESSION, content: 'ref', isStatic: true }, value: { - type: NodeTypes.JS_FUNCTION_EXPRESSION, - params: ['_value', '_refs'], - body: { - type: NodeTypes.JS_BLOCK_STATEMENT, - body: [ - { - content: `_refs['input'] = _value` - } - ] - } - } - } - ] - }) - }) - - test('the binding not exists (inline maybe ref input)', () => { - const { node } = parseWithElementTransform(``, { - inline: true, - bindingMetadata: { - input: BindingTypes.SETUP_MAYBE_REF - } - }) - expect(node.props).toMatchObject({ - type: NodeTypes.JS_OBJECT_EXPRESSION, - properties: [ - { - type: NodeTypes.JS_PROPERTY, - key: { - type: NodeTypes.SIMPLE_EXPRESSION, - content: 'ref', + content: 'input', isStatic: true - }, - value: { - type: NodeTypes.JS_FUNCTION_EXPRESSION, - params: ['_value', '_refs'], - body: { - type: NodeTypes.JS_BLOCK_STATEMENT, - body: [ - { - content: `_refs['input'] = _value` - }, - { - content: '_isRef(input) && (input.value = _value)' - } - ] - } - } - } - ] - }) - }) - - test('the binding not exists (inline let ref input)', () => { - const { node } = parseWithElementTransform(``, { - inline: true, - bindingMetadata: { - input: BindingTypes.SETUP_LET - } - }) - expect(node.props).toMatchObject({ - type: NodeTypes.JS_OBJECT_EXPRESSION, - properties: [ - { - type: NodeTypes.JS_PROPERTY, - key: { - type: NodeTypes.SIMPLE_EXPRESSION, - content: 'ref', - isStatic: true - }, - value: { - type: NodeTypes.JS_FUNCTION_EXPRESSION, - params: ['_value', '_refs'], - body: { - type: NodeTypes.JS_BLOCK_STATEMENT, - body: [ - { - content: `_refs['input'] = _value` - }, - { - content: - '_isRef(input) ? input.value = _value : input = _value' - } - ] - } } } ] diff --git a/packages/compiler-core/src/compat/compatConfig.ts b/packages/compiler-core/src/compat/compatConfig.ts index d43c441d..717b8dc4 100644 --- a/packages/compiler-core/src/compat/compatConfig.ts +++ b/packages/compiler-core/src/compat/compatConfig.ts @@ -20,7 +20,6 @@ export const enum CompilerDeprecationTypes { COMPILER_V_BIND_OBJECT_ORDER = 'COMPILER_V_BIND_OBJECT_ORDER', COMPILER_V_ON_NATIVE = 'COMPILER_V_ON_NATIVE', COMPILER_V_IF_V_FOR_PRECEDENCE = 'COMPILER_V_IF_V_FOR_PRECEDENCE', - COMPILER_V_FOR_REF = 'COMPILER_V_FOR_REF', COMPILER_NATIVE_TEMPLATE = 'COMPILER_NATIVE_TEMPLATE', COMPILER_INLINE_TEMPLATE = 'COMPILER_INLINE_TEMPLATE', COMPILER_FILTERS = 'COMPILER_FILTER' @@ -79,13 +78,6 @@ const deprecationData: Record = { link: `https://v3.vuejs.org/guide/migration/v-if-v-for.html` }, - [CompilerDeprecationTypes.COMPILER_V_FOR_REF]: { - message: - `Ref usage on v-for no longer creates array ref values in Vue 3. ` + - `Consider using function refs or refactor to avoid ref usage altogether.`, - link: `https://v3.vuejs.org/guide/migration/array-refs.html` - }, - [CompilerDeprecationTypes.COMPILER_NATIVE_TEMPLATE]: { message: `