Skip to content

Commit 0270da0

Browse files
committed
Work around a reparenting issue in RadSideDrawer.
Solves the problem of attaching a node and immediately moving it to another location in the visual tree without Angular noticing. That breaks the next attach as it will attach nodes to the new location instead of the original one. This should not be supported. Revert once we ship a fix for RadSideDrawer.
1 parent 7970152 commit 0270da0

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

src/nativescript-angular/renderer.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,11 +114,17 @@ export class NativeScriptRenderer extends Renderer {
114114

115115
attachViewAfter(anchorNode: NgView, viewRootNodes: NgView[]) {
116116
traceLog('NativeScriptRenderer.attachViewAfter: ' + anchorNode.nodeName + ' ' + anchorNode);
117-
const parent = (<NgView>anchorNode.parent || anchorNode.templateParent);
117+
//HACK: The anchor.templateParent precedence and child.templateParent
118+
//assignment are a workaround for RadSideDrawer.
119+
//Remove it once we ship the fix in the RadSideDrawer directives.
120+
const parent = (anchorNode.templateParent || <NgView>anchorNode.parent);
118121
const insertPosition = this.viewUtil.getChildIndex(parent, anchorNode);
119122

120123
viewRootNodes.forEach((node, index) => {
121124
const childIndex = insertPosition + index + 1;
125+
//Remember the template parent in case someone moves the view element
126+
//before Angular attaches the next view.
127+
node.templateParent = parent;
122128
this.viewUtil.insertChild(parent, node, childIndex);
123129
this.animateNodeEnter(node);
124130
});

0 commit comments

Comments
 (0)