-
Notifications
You must be signed in to change notification settings - Fork 784
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(runtime): make isSameVnode return false on initial render in a hy…
…dration case (#5891) * fix(runtime): make isSameVnode return false on initial render in a hydration case * prettier
- Loading branch information
1 parent
a7c212c
commit 82a7bb9
Showing
2 changed files
with
52 additions
and
0 deletions.
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,39 @@ | ||
import { isSameVnode } from '../vdom-render'; | ||
|
||
describe('isSameVnode', () => { | ||
it('should detect objectively same nodes', () => { | ||
const vnode1: any = { | ||
$tag$: 'div', | ||
$key$: '1', | ||
$elm$: { nodeType: 9 }, | ||
}; | ||
const vnode2: any = { | ||
$tag$: 'div', | ||
$key$: '1', | ||
$elm$: { nodeType: 9 }, | ||
}; | ||
expect(isSameVnode(vnode1, vnode2)).toBe(true); | ||
}); | ||
|
||
it('should return false in case of hyration', () => { | ||
const vnode1: any = { | ||
$tag$: 'slot', | ||
$key$: '1', | ||
$elm$: { nodeType: 9 }, | ||
$nodeId$: 1, | ||
}; | ||
const vnode2: any = { | ||
$tag$: 'slot', | ||
$key$: '1', | ||
$elm$: { nodeType: 9 }, | ||
}; | ||
const vnode3: any = { | ||
$tag$: 'slot', | ||
$key$: '1', | ||
$elm$: { nodeType: 8 }, | ||
$nodeId$: 2, | ||
}; | ||
expect(isSameVnode(vnode1, vnode2, true)).toBe(false); | ||
expect(isSameVnode(vnode3, vnode2, true)).toBe(true); | ||
}); | ||
}); |
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