Skip to content

Commit fb7f5f0

Browse files
committed
chore: remove unused code
Vue 2 has no inline mode so template ref ref_key logic is unnecessary
1 parent 65531f5 commit fb7f5f0

File tree

2 files changed

+23
-26
lines changed

2 files changed

+23
-26
lines changed

src/core/vdom/modules/template-ref.ts

-3
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,6 @@ export function registerRef(vnode: VNodeWithData, isRemoval?: boolean) {
4040
return
4141
}
4242

43-
const setupRefKey = vnode.data.ref_key
4443
const isFor = vnode.data.refInFor
4544
const _isString = typeof ref === 'string' || typeof ref === 'number'
4645
const _isRef = isRef(ref)
@@ -58,7 +57,6 @@ export function registerRef(vnode: VNodeWithData, isRemoval?: boolean) {
5857
setSetupRef(vm, ref, refs[ref])
5958
} else {
6059
ref.value = [refValue]
61-
if (setupRefKey) refs[setupRefKey] = ref.value as any
6260
}
6361
} else if (!existing.includes(refValue)) {
6462
existing.push(refValue)
@@ -75,7 +73,6 @@ export function registerRef(vnode: VNodeWithData, isRemoval?: boolean) {
7573
return
7674
}
7775
ref.value = value
78-
if (setupRefKey) refs[setupRefKey] = $refsValue
7976
} else if (__DEV__) {
8077
warn(`Invalid template ref type: ${typeof ref}`)
8178
}

test/unit/features/v3/setupTemplateRef.spec.ts

+23-23
Original file line numberDiff line numberDiff line change
@@ -371,33 +371,33 @@ describe('api: setup() template refs', () => {
371371
// expect(elRef1.value).toBe(elRef2.value)
372372
// })
373373

374-
// compiled output of <script setup> inline mode
375-
test('raw ref with ref_key', () => {
376-
let refs: any
374+
// Vue 2 doesn't have inline mode
375+
// test('raw ref with ref_key', () => {
376+
// let refs: any
377377

378-
const el = ref()
378+
// const el = ref()
379379

380-
const App = {
381-
mounted() {
382-
refs = (this as any).$refs
383-
},
384-
render() {
385-
return h(
386-
'div',
387-
{
388-
ref: el,
389-
ref_key: 'el'
390-
},
391-
'hello'
392-
)
393-
}
394-
}
380+
// const App = {
381+
// mounted() {
382+
// refs = (this as any).$refs
383+
// },
384+
// render() {
385+
// return h(
386+
// 'div',
387+
// {
388+
// ref: el,
389+
// ref_key: 'el'
390+
// },
391+
// 'hello'
392+
// )
393+
// }
394+
// }
395395

396-
new Vue(App).$mount()
396+
// new Vue(App).$mount()
397397

398-
expect(el.value.innerHTML).toBe('hello')
399-
expect(refs.el.innerHTML).toBe('hello')
400-
})
398+
// expect(el.value.innerHTML).toBe('hello')
399+
// expect(refs.el.innerHTML).toBe('hello')
400+
// })
401401

402402
// compiled output of v-for + template ref
403403
test('ref in v-for', async () => {

0 commit comments

Comments
 (0)