@@ -224,6 +224,7 @@ export class ViewUtil {
224
224
NativeScriptDebug . viewUtilLog ( `ViewUtil.removeFromList parent: ${ parent } child: ${ child } ` ) ;
225
225
}
226
226
227
+ // only child. null everything
227
228
if ( parent . firstChild === child && parent . lastChild === child ) {
228
229
parent . firstChild = null ;
229
230
parent . lastChild = null ;
@@ -232,22 +233,29 @@ export class ViewUtil {
232
233
return ;
233
234
}
234
235
236
+ const previous = child . previousSibling ;
237
+ const next = child . nextSibling ;
238
+ // is first child, make the next sibling the first child (can be null)
235
239
if ( parent . firstChild === child ) {
236
- parent . firstChild = child . nextSibling ;
240
+ parent . firstChild = next ;
237
241
}
238
242
239
- const previous = child . previousSibling ;
243
+ // is last child, make the previous sibling the last child (can be null)
240
244
if ( parent . lastChild === child ) {
241
245
parent . lastChild = previous ;
242
246
}
243
247
248
+ // we have a previous sibling, make it point to the next sibling
244
249
if ( previous ) {
245
- previous . nextSibling = child . nextSibling ;
246
- if ( child . nextSibling ) {
247
- child . nextSibling . previousSibling = previous ;
248
- }
250
+ previous . nextSibling = next ;
251
+ }
252
+
253
+ // we have a next sibling, make it point to the previous
254
+ if ( next ) {
255
+ next . previousSibling = previous ;
249
256
}
250
257
258
+ // finally, null the siblings
251
259
child . nextSibling = null ;
252
260
child . previousSibling = null ;
253
261
}
0 commit comments