File tree Expand file tree Collapse file tree 3 files changed +5
-26
lines changed Expand file tree Collapse file tree 3 files changed +5
-26
lines changed Original file line number Diff line number Diff line change @@ -62,8 +62,7 @@ export function createHydrationFunctions(
62
62
parentNode,
63
63
remove,
64
64
insert,
65
- createComment,
66
- replace
65
+ createComment
67
66
}
68
67
} = rendererInternals
69
68
@@ -622,7 +621,10 @@ export function createHydrationFunctions(
622
621
parentComponent : ComponentInternalInstance | null
623
622
) : Node => {
624
623
// replace node
625
- replace ( newNode , oldNode )
624
+ const parentNode = oldNode . parentNode
625
+ if ( parentNode ) {
626
+ parentNode . replaceChild ( newNode , oldNode )
627
+ }
626
628
627
629
// update vnode
628
630
let parent = parentComponent
Original file line number Diff line number Diff line change @@ -105,7 +105,6 @@ export interface RendererOptions<
105
105
) : void
106
106
insert ( el : HostNode , parent : HostElement , anchor ?: HostNode | null ) : void
107
107
remove ( el : HostNode ) : void
108
- replace ( newChild : HostNode , oldChild : HostNode ) : void
109
108
createElement (
110
109
type : string ,
111
110
isSVG ?: boolean ,
Original file line number Diff line number Diff line change @@ -188,28 +188,6 @@ function remove(child: TestNode, logOp = true) {
188
188
}
189
189
}
190
190
191
- function replace ( newChild : TestNode , oldChild : TestNode , logOp = true ) {
192
- const parent = oldChild . parentNode
193
- if ( parent ) {
194
- if ( logOp ) {
195
- logNodeOp ( {
196
- type : NodeOpTypes . REMOVE ,
197
- targetNode : oldChild ,
198
- parentNode : parent
199
- } )
200
- }
201
- const i = parent . children . indexOf ( oldChild )
202
- if ( i > - 1 ) {
203
- parent . children . splice ( i , 1 , newChild )
204
- } else {
205
- console . error ( 'target: ' , oldChild )
206
- console . error ( 'parent: ' , parent )
207
- throw Error ( 'target is not a childNode of parent' )
208
- }
209
- oldChild . parentNode = null
210
- }
211
- }
212
-
213
191
function setElementText ( el : TestElement , text : string ) {
214
192
logNodeOp ( {
215
193
type : NodeOpTypes . SET_ELEMENT_TEXT ,
You can’t perform that action at this time.
0 commit comments