Skip to content

Commit

Permalink
fix(runtime-core):format code vuejs#6697
Browse files Browse the repository at this point in the history
  • Loading branch information
baiwusanyu-c committed Oct 3, 2022
1 parent 052eb8f commit b6b2abf
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 25 deletions.
48 changes: 25 additions & 23 deletions packages/runtime-core/__tests__/rendererTemplateRef.spec.ts
Expand Up @@ -503,38 +503,40 @@ describe('api: template refs', () => {
return { listRefs }
},
render() {
return h(
'div',
null,
[
h('div',null,String(listRefs.value)),
h(
'ul',
list.value.map(i =>
h(
'li',
{
ref: 'listRefs',
ref_for: true
},
i
)
)
)
]
return h('div', null, [
h('div', null, String(listRefs.value)),
h(
'ul',
list.value.map(i =>
h(
'li',
{
ref: 'listRefs',
ref_for: true
},
i
)
)
)
])
}
}
const root = nodeOps.createElement('div')
render(h(App), root)

await nextTick()
expect(String(listRefs.value)).toBe('[object Object],[object Object],[object Object]')
expect(serializeInner(root)).toBe('<div><div>[object Object],[object Object],[object Object]</div><ul><li>1</li><li>2</li><li>3</li></ul></div>')
expect(String(listRefs.value)).toBe(
'[object Object],[object Object],[object Object]'
)
expect(serializeInner(root)).toBe(
'<div><div>[object Object],[object Object],[object Object]</div><ul><li>1</li><li>2</li><li>3</li></ul></div>'
)

list.value.splice(0,1);
list.value.splice(0, 1)
await nextTick()
expect(String(listRefs.value)).toBe('[object Object],[object Object]')
expect(serializeInner(root)).toBe('<div><div>[object Object],[object Object]</div><ul><li>2</li><li>3</li></ul></div>')
expect(serializeInner(root)).toBe(
'<div><div>[object Object],[object Object]</div><ul><li>2</li><li>3</li></ul></div>'
)
})
})
5 changes: 3 additions & 2 deletions packages/runtime-core/src/rendererTemplateRef.ts
Expand Up @@ -12,7 +12,7 @@ import {
import { isAsyncWrapper } from './apiAsyncComponent'
import { getExposeProxy } from './component'
import { warn } from './warning'
import {isRef, reactive} from '@vue/reactivity'
import { isRef, reactive } from '@vue/reactivity'
import { callWithErrorHandling, ErrorCodes } from './errorHandling'
import { SchedulerJob } from './scheduler'
import { queuePostRenderEffect } from './renderer'
Expand Down Expand Up @@ -61,7 +61,8 @@ export function setRef(
return
}
const oldRef = oldRawRef && (oldRawRef as VNodeNormalizedRefAtom).r
const refs = owner.refs === EMPTY_OBJ ? (owner.refs = reactive({})) : owner.refs
const refs =
owner.refs === EMPTY_OBJ ? (owner.refs = reactive({})) : owner.refs
const setupState = owner.setupState

// dynamic ref changed. unset old ref
Expand Down

0 comments on commit b6b2abf

Please sign in to comment.