Skip to content

fix: better handling of parentNode on detached elements #86

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Sep 10, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 3 additions & 5 deletions packages/angular/src/lib/view-util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -90,12 +90,9 @@ export class ViewUtil {
// no previous or next, append to the parent
previous = extendedParent.lastChild; // this can still be undefined if the parent has no children!
}
// Note: handle case with listview nodes
if (extendedChild !== previous && extendedChild !== next) {
this.insertInList(extendedParent, extendedChild, previous, next);
}
this.insertInList(extendedParent, extendedChild, previous, next);

if (isInvisibleNode(child)) {
if (isDetachedElement(child) || isInvisibleNode(child)) {
extendedChild.parentNode = extendedParent;
}

Expand Down Expand Up @@ -212,6 +209,7 @@ export class ViewUtil {

const extendedParent = this.ensureNgViewExtensions(parent);
const extendedChild = this.ensureNgViewExtensions(child);
extendedChild.parentNode = null;

this.removeFromList(extendedParent, extendedChild);
if (!isDetachedElement(extendedChild)) {
Expand Down
4 changes: 2 additions & 2 deletions packages/angular/src/lib/views/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,9 @@ export function getFirstNativeLikeView(view: View, extractFromNSParent = false)
}

if (extractFromNSParent) {
// const node = view.parentNode;
const node = view.parentNode;
detachViewFromParent(view);
// view.parentNode = node;
view.parentNode = node;
}
return view;
}
Expand Down