@@ -138,8 +138,10 @@ function mountDOMElement(dom, internal, globalContext, commitQueue) {
138
138
}
139
139
}
140
140
141
+ let isNew = dom == null ;
142
+
141
143
if ( flags & TYPE_TEXT ) {
142
- if ( dom == null ) {
144
+ if ( isNew ) {
143
145
// @ts -ignore createTextNode returns Text, we expect PreactElement
144
146
dom = document . createTextNode ( newProps ) ;
145
147
} else if ( dom . data !== newProps ) {
@@ -151,7 +153,7 @@ function mountDOMElement(dom, internal, globalContext, commitQueue) {
151
153
// Tracks entering and exiting SVG namespace when descending through the tree.
152
154
// if (nodeType === 'svg') internal._flags |= MODE_SVG;
153
155
154
- if ( dom == null ) {
156
+ if ( isNew ) {
155
157
if ( isSvg ) {
156
158
dom = document . createElementNS (
157
159
'http://www.w3.org/2000/svg' ,
@@ -167,7 +169,7 @@ function mountDOMElement(dom, internal, globalContext, commitQueue) {
167
169
}
168
170
169
171
// we are creating a new node, so we can assume this is a new subtree (in case we are hydrating), this deopts the hydrate
170
- internal . _flags &= RESET_MODE ;
172
+ internal . _flags = flags &= RESET_MODE ;
171
173
isFullRender = 1 ;
172
174
}
173
175
@@ -218,7 +220,7 @@ function mountDOMElement(dom, internal, globalContext, commitQueue) {
218
220
internal ,
219
221
globalContext ,
220
222
commitQueue ,
221
- dom . firstChild
223
+ isNew ? null : dom . firstChild
222
224
) ;
223
225
}
224
226
@@ -229,7 +231,7 @@ function mountDOMElement(dom, internal, globalContext, commitQueue) {
229
231
}
230
232
231
233
// @ts -ignore
232
- return dom . nextSibling ;
234
+ return isNew ? null : dom . nextSibling ;
233
235
}
234
236
235
237
/**
@@ -251,21 +253,25 @@ export function mountChildren(
251
253
commitQueue ,
252
254
startDom
253
255
) {
254
- let i , childVNode , childInternal , newDom , mountedNextChild ;
256
+ let internalChildren = ( parentInternal . _children = [ ] ) ,
257
+ i ,
258
+ childVNode ,
259
+ childInternal ,
260
+ newDom ,
261
+ mountedNextChild ;
255
262
256
- parentInternal . _children = [ ] ;
257
263
for ( i = 0 ; i < renderResult . length ; i ++ ) {
258
264
childVNode = normalizeToVNode ( renderResult [ i ] ) ;
259
265
260
266
// Terser removes the `continue` here and wraps the loop body
261
267
// in a `if (childVNode) { ... } condition
262
268
if ( childVNode == null ) {
263
- parentInternal . _children [ i ] = null ;
269
+ internalChildren [ i ] = null ;
264
270
continue ;
265
271
}
266
272
267
273
childInternal = createInternal ( childVNode , parentInternal ) ;
268
- parentInternal . _children [ i ] = childInternal ;
274
+ internalChildren [ i ] = childInternal ;
269
275
270
276
// Morph the old element into the new one, but don't append it to the dom yet
271
277
mountedNextChild = mount (
0 commit comments