-
-
Notifications
You must be signed in to change notification settings - Fork 8.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(runtime-core): fix parent el update on nested HOC self-update (#1360
) fix #1357
- Loading branch information
Showing
2 changed files
with
47 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
import { | ||
ref, | ||
h, | ||
render, | ||
nodeOps, | ||
serializeInner, | ||
nextTick, | ||
VNode | ||
} from '@vue/runtime-test' | ||
|
||
describe('renderer: component', () => { | ||
test('should update parent(hoc) component host el when child component self update', async () => { | ||
const value = ref(true) | ||
let parentVnode: VNode | ||
let childVnode1: VNode | ||
let childVnode2: VNode | ||
|
||
const Parent = { | ||
render: () => { | ||
// let Parent first rerender | ||
console.log(value.value) | ||
return (parentVnode = h(Child)) | ||
} | ||
} | ||
|
||
const Child = { | ||
render: () => { | ||
return value.value | ||
? (childVnode1 = h('div')) | ||
: (childVnode2 = h('span')) | ||
} | ||
} | ||
|
||
const root = nodeOps.createElement('div') | ||
render(h(Parent), root) | ||
expect(serializeInner(root)).toBe(`<div></div>`) | ||
expect(parentVnode!.el).toBe(childVnode1!.el) | ||
|
||
value.value = false | ||
await nextTick() | ||
expect(serializeInner(root)).toBe(`<span></span>`) | ||
expect(parentVnode!.el).toBe(childVnode2!.el) | ||
}) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters