فهرست منبع

chore: remove unused code

Vue 2 has no inline mode so template ref ref_key logic is unnecessary
Evan You 3 سال پیش
والد
کامیت
fb7f5f0b67
2فایلهای تغییر یافته به همراه23 افزوده شده و 26 حذف شده
  1. 0 3
      src/core/vdom/modules/template-ref.ts
  2. 23 23
      test/unit/features/v3/setupTemplateRef.spec.ts

+ 0 - 3
src/core/vdom/modules/template-ref.ts

@@ -40,7 +40,6 @@ export function registerRef(vnode: VNodeWithData, isRemoval?: boolean) {
     return
   }
 
-  const setupRefKey = vnode.data.ref_key
   const isFor = vnode.data.refInFor
   const _isString = typeof ref === 'string' || typeof ref === 'number'
   const _isRef = isRef(ref)
@@ -58,7 +57,6 @@ export function registerRef(vnode: VNodeWithData, isRemoval?: boolean) {
             setSetupRef(vm, ref, refs[ref])
           } else {
             ref.value = [refValue]
-            if (setupRefKey) refs[setupRefKey] = ref.value as any
           }
         } else if (!existing.includes(refValue)) {
           existing.push(refValue)
@@ -75,7 +73,6 @@ export function registerRef(vnode: VNodeWithData, isRemoval?: boolean) {
         return
       }
       ref.value = value
-      if (setupRefKey) refs[setupRefKey] = $refsValue
     } else if (__DEV__) {
       warn(`Invalid template ref type: ${typeof ref}`)
     }

+ 23 - 23
test/unit/features/v3/setupTemplateRef.spec.ts

@@ -371,33 +371,33 @@ describe('api: setup() template refs', () => {
   //   expect(elRef1.value).toBe(elRef2.value)
   // })
 
-  // compiled output of <script setup> inline mode
-  test('raw ref with ref_key', () => {
-    let refs: any
+  // Vue 2 doesn't have inline mode
+  // test('raw ref with ref_key', () => {
+  //   let refs: any
 
-    const el = ref()
+  //   const el = ref()
 
-    const App = {
-      mounted() {
-        refs = (this as any).$refs
-      },
-      render() {
-        return h(
-          'div',
-          {
-            ref: el,
-            ref_key: 'el'
-          },
-          'hello'
-        )
-      }
-    }
+  //   const App = {
+  //     mounted() {
+  //       refs = (this as any).$refs
+  //     },
+  //     render() {
+  //       return h(
+  //         'div',
+  //         {
+  //           ref: el,
+  //           ref_key: 'el'
+  //         },
+  //         'hello'
+  //       )
+  //     }
+  //   }
 
-    new Vue(App).$mount()
+  //   new Vue(App).$mount()
 
-    expect(el.value.innerHTML).toBe('hello')
-    expect(refs.el.innerHTML).toBe('hello')
-  })
+  //   expect(el.value.innerHTML).toBe('hello')
+  //   expect(refs.el.innerHTML).toBe('hello')
+  // })
 
   // compiled output of v-for + template ref
   test('ref in v-for', async () => {