From cc28c572a338c87fe7f4d249865f8c4f72e02248 Mon Sep 17 00:00:00 2001 From: Eduardo Speroni Date: Tue, 4 Oct 2022 18:17:47 -0300 Subject: [PATCH] fix: remove child from previous parent if needed due to animations --- packages/angular/src/lib/view-util.ts | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/packages/angular/src/lib/view-util.ts b/packages/angular/src/lib/view-util.ts index 5704783..0b5e39f 100644 --- a/packages/angular/src/lib/view-util.ts +++ b/packages/angular/src/lib/view-util.ts @@ -80,6 +80,12 @@ export class ViewUtil { const extendedParent = this.ensureNgViewExtensions(parent); const extendedChild = this.ensureNgViewExtensions(child); + // this should never enter, as angular is supposed to remove the child from the previous parent before calling this + // but when angular animations are enabled, the removal might be delayed, so we need to ensure this view is not anywhere + // this seems to only happens to CommentNodes + if (extendedChild.parentNode) { + this.removeChild(extendedChild.parentNode, extendedChild); + } // if there's a next child, previous is the previousSibling of it if (next) { previous = next.previousSibling;