chore: remove unused code

Vue 2 has no inline mode so template ref ref_key logic is unnecessary
This commit is contained in:
Evan You 2022-06-22 10:12:52 +08:00
parent 65531f5803
commit fb7f5f0b67
2 changed files with 23 additions and 26 deletions

View File

@ -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}`)
}

View File

@ -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 () => {