2017-12-01 14:23:03 -08:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								/**
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								 * @license
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								 * Copyright Google Inc. All Rights Reserved.
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								 *
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								 * Use of this source code is governed by an MIT-style license that can be
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								 * found in the LICENSE file at https://angular.io/license
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								 */
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							
								
									
										
										
										
											2018-07-03 20:04:36 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								import {assertDefined} from './assert';
							 | 
						
					
						
							
								
									
										
										
										
											2018-01-25 20:41:57 -08:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								import {callHooks} from './hooks';
							 | 
						
					
						
							
								
									
										
										
										
											2018-06-07 22:42:32 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								import {LContainer, RENDER_PARENT, VIEWS, unusedValueExportToPlacateAjd as unused1} from './interfaces/container';
							 | 
						
					
						
							
								
									
										
										
										
											2018-07-26 17:22:41 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								import {LContainerNode, LElementContainerNode, LElementNode, LNode, LProjectionNode, LTextNode, LViewNode, TNode, TNodeFlags, TNodeType, unusedValueExportToPlacateAjd as unused2} from './interfaces/node';
							 | 
						
					
						
							
								
									
										
										
										
											2018-01-25 15:32:21 +01:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								import {unusedValueExportToPlacateAjd as unused3} from './interfaces/projection';
							 | 
						
					
						
							
								
									
										
										
										
											2018-06-06 17:30:48 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								import {ProceduralRenderer3, RComment, RElement, RNode, RText, Renderer3, isProceduralRenderer, unusedValueExportToPlacateAjd as unused4} from './interfaces/renderer';
							 | 
						
					
						
							
								
									
										
										
										
											2018-06-26 11:39:56 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								import {CLEANUP, CONTAINER_INDEX, DIRECTIVES, FLAGS, HEADER_OFFSET, HOST_NODE, HookData, LViewData, LViewFlags, NEXT, PARENT, QUERIES, RENDERER, TVIEW, unusedValueExportToPlacateAjd as unused5} from './interfaces/view';
							 | 
						
					
						
							
								
									
										
										
										
											2018-06-22 15:37:38 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								import {assertNodeOfPossibleTypes, assertNodeType} from './node_assert';
							 | 
						
					
						
							
								
									
										
										
										
											2018-07-11 09:56:47 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								import {readElementValue, stringify} from './util';
							 | 
						
					
						
							
								
									
										
										
										
											2017-12-14 15:03:46 -08:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							
								
									
										
										
										
											2018-01-11 13:09:21 -08:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								const unusedValueToPlacateAjd = unused1 + unused2 + unused3 + unused4 + unused5;
							 | 
						
					
						
							
								
									
										
										
										
											2017-12-20 10:47:22 -08:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							
								
									
										
										
										
											2018-05-11 20:57:37 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								/** Retrieves the sibling node for the given node. */
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								export function getNextLNode(node: LNode): LNode|null {
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								  // View nodes don't have TNodes, so their next must be retrieved through their LView.
							 | 
						
					
						
							
								
									
										
										
										
											2018-05-17 12:54:57 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								  if (node.tNode.type === TNodeType.View) {
							 | 
						
					
						
							
								
									
										
										
										
											2018-06-07 22:42:32 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    const viewData = node.data as LViewData;
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    return viewData[NEXT] ? (viewData[NEXT] as LViewData)[HOST_NODE] : null;
							 | 
						
					
						
							
								
									
										
										
										
											2018-05-11 20:57:37 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								  }
							 | 
						
					
						
							
								
									
										
										
										
											2018-07-03 20:04:36 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								  return node.tNode.next ? node.view[node.tNode.next.index] : null;
							 | 
						
					
						
							
								
									
										
										
										
											2018-05-11 20:57:37 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								}
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							
								
									
										
										
										
											2018-05-24 13:13:51 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								/** Retrieves the first child of a given node */
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								export function getChildLNode(node: LNode): LNode|null {
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								  if (node.tNode.child) {
							 | 
						
					
						
							
								
									
										
										
										
											2018-06-07 22:42:32 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    const viewData = node.tNode.type === TNodeType.View ? node.data as LViewData : node.view;
							 | 
						
					
						
							
								
									
										
										
										
											2018-07-11 09:56:47 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    return readElementValue(viewData[node.tNode.child.index]);
							 | 
						
					
						
							
								
									
										
										
										
											2018-05-24 13:13:51 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								  }
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								  return null;
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								}
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							
								
									
										
										
										
											2018-05-29 15:08:30 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								/** Retrieves the parent LNode of a given node. */
							 | 
						
					
						
							
								
									
										
										
										
											2018-07-26 17:22:41 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								export function getParentLNode(
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    node: LContainerNode | LElementNode | LElementContainerNode | LTextNode |
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    LProjectionNode): LElementNode|LElementContainerNode|LViewNode;
							 | 
						
					
						
							
								
									
										
										
										
											2018-05-29 15:08:30 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								export function getParentLNode(node: LViewNode): LContainerNode|null;
							 | 
						
					
						
							
								
									
										
										
										
											2018-07-26 17:22:41 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								export function getParentLNode(node: LNode): LElementNode|LElementContainerNode|LContainerNode|
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    LViewNode|null;
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								export function getParentLNode(node: LNode): LElementNode|LElementContainerNode|LContainerNode|
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    LViewNode|null {
							 | 
						
					
						
							
								
									
										
										
										
											2018-06-26 11:39:56 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								  if (node.tNode.index === -1 && node.tNode.type === TNodeType.View) {
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    // This is a dynamically created view inside a dynamic container.
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    // If the host index is -1, the view has not yet been inserted, so it has no parent.
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    const containerHostIndex = (node.data as LViewData)[CONTAINER_INDEX];
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    return containerHostIndex === -1 ? null : node.view[containerHostIndex].dynamicLContainerNode;
							 | 
						
					
						
							
								
									
										
										
										
											2018-06-18 18:07:05 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								  }
							 | 
						
					
						
							
								
									
										
										
										
											2018-05-29 15:08:30 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								  const parent = node.tNode.parent;
							 | 
						
					
						
							
								
									
										
										
										
											2018-07-11 09:56:47 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								  return readElementValue(parent ? node.view[parent.index] : node.view[HOST_NODE]);
							 | 
						
					
						
							
								
									
										
										
										
											2018-05-29 15:08:30 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								}
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							
								
									
										
										
										
											2018-05-31 15:45:46 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								const enum WalkLNodeTreeAction {
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								  /** node insert in the native environment */
							 | 
						
					
						
							
								
									
										
										
										
											2018-06-06 17:30:48 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								  Insert = 0,
							 | 
						
					
						
							
								
									
										
										
										
											2018-05-31 15:45:46 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								  /** node detach from the native environment */
							 | 
						
					
						
							
								
									
										
										
										
											2018-06-06 17:30:48 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								  Detach = 1,
							 | 
						
					
						
							
								
									
										
										
										
											2018-05-31 15:45:46 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								  /** node destruction using the renderer's API */
							 | 
						
					
						
							
								
									
										
										
										
											2018-06-06 17:30:48 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								  Destroy = 2,
							 | 
						
					
						
							
								
									
										
										
										
											2018-05-31 15:45:46 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								}
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							
								
									
										
										
										
											2018-07-03 20:04:36 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								/**
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								 * Stack used to keep track of projection nodes in walkLNodeTree.
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								 *
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								 * This is deliberately created outside of walkLNodeTree to avoid allocating
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								 * a new array each time the function is called. Instead the array will be
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								 * re-used by each invocation. This works because the function is not reentrant.
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								 */
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								const projectionNodeStack: LProjectionNode[] = [];
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							
								
									
										
										
										
											2018-05-31 15:45:46 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								/**
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								 * Walks a tree of LNodes, applying a transformation on the LElement nodes, either only on the first
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								 * one found, or on all of them.
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								 *
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								 * @param startingNode the node from which the walk is started.
							 | 
						
					
						
							
								
									
										
										
										
											2018-07-03 20:04:36 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								 * @param rootNode the root node considered. This prevents walking past that node.
							 | 
						
					
						
							
								
									
										
										
										
											2018-06-06 17:30:48 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								 * @param action identifies the action to be performed on the LElement nodes.
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								 * @param renderer the current renderer.
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								 * @param renderParentNode Optional the render parent node to be set in all LContainerNodes found,
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								 * required for action modes Insert and Destroy.
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								 * @param beforeNode Optional the node before which elements should be added, required for action
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								 * Insert.
							 | 
						
					
						
							
								
									
										
										
										
											2018-05-31 15:45:46 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								 */
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								function walkLNodeTree(
							 | 
						
					
						
							
								
									
										
										
										
											2018-06-06 17:30:48 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    startingNode: LNode | null, rootNode: LNode, action: WalkLNodeTreeAction, renderer: Renderer3,
							 | 
						
					
						
							
								
									
										
										
										
											2018-05-31 15:45:46 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    renderParentNode?: LElementNode | null, beforeNode?: RNode | null) {
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								  let node: LNode|null = startingNode;
							 | 
						
					
						
							
								
									
										
										
										
											2018-07-03 20:04:36 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								  let projectionNodeIndex = -1;
							 | 
						
					
						
							
								
									
										
										
										
											2018-01-25 15:32:21 +01:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								  while (node) {
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    let nextNode: LNode|null = null;
							 | 
						
					
						
							
								
									
										
										
										
											2018-06-06 17:30:48 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    const parent = renderParentNode ? renderParentNode.native : null;
							 | 
						
					
						
							
								
									
										
										
										
											2018-07-03 20:04:36 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    const nodeType = node.tNode.type;
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    if (nodeType === TNodeType.Element) {
							 | 
						
					
						
							
								
									
										
										
										
											2018-05-31 15:45:46 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								      // Execute the action
							 | 
						
					
						
							
								
									
										
										
										
											2018-06-06 17:30:48 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								      executeNodeAction(action, renderer, parent, node.native !, beforeNode);
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								      if (node.dynamicLContainerNode) {
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								        executeNodeAction(
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								            action, renderer, parent, node.dynamicLContainerNode.native !, beforeNode);
							 | 
						
					
						
							
								
									
										
										
										
											2018-05-31 15:45:46 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								      }
							 | 
						
					
						
							
								
									
										
										
										
											2018-07-03 20:04:36 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    } else if (nodeType === TNodeType.Container) {
							 | 
						
					
						
							
								
									
										
										
										
											2018-06-06 17:30:48 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								      executeNodeAction(action, renderer, parent, node.native !, beforeNode);
							 | 
						
					
						
							
								
									
										
										
										
											2018-04-03 10:18:25 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								      const lContainerNode: LContainerNode = (node as LContainerNode);
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								      const childContainerData: LContainer = lContainerNode.dynamicLContainerNode ?
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								          lContainerNode.dynamicLContainerNode.data :
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								          lContainerNode.data;
							 | 
						
					
						
							
								
									
										
										
										
											2018-05-31 15:45:46 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								      if (renderParentNode) {
							 | 
						
					
						
							
								
									
										
										
										
											2018-06-07 22:42:32 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								        childContainerData[RENDER_PARENT] = renderParentNode;
							 | 
						
					
						
							
								
									
										
										
										
											2018-05-31 15:45:46 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								      }
							 | 
						
					
						
							
								
									
										
										
										
											2018-05-24 13:13:51 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								      nextNode =
							 | 
						
					
						
							
								
									
										
										
										
											2018-06-07 22:42:32 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								          childContainerData[VIEWS].length ? getChildLNode(childContainerData[VIEWS][0]) : null;
							 | 
						
					
						
							
								
									
										
										
										
											2018-06-06 17:30:48 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								      if (nextNode) {
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								        // When the walker enters a container, then the beforeNode has to become the local native
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								        // comment node.
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								        beforeNode = lContainerNode.dynamicLContainerNode ?
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								            lContainerNode.dynamicLContainerNode.native :
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								            lContainerNode.native;
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								      }
							 | 
						
					
						
							
								
									
										
										
										
											2018-07-03 20:04:36 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    } else if (nodeType === TNodeType.Projection) {
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								      const componentHost = findComponentHost(node.view);
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								      const head =
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								          (componentHost.tNode.projection as(TNode | null)[])[node.tNode.projection as number];
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								      projectionNodeStack[++projectionNodeIndex] = node as LProjectionNode;
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								      nextNode = head ? (componentHost.data as LViewData)[PARENT] ![head.index] : null;
							 | 
						
					
						
							
								
									
										
										
										
											2018-01-25 15:32:21 +01:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    } else {
							 | 
						
					
						
							
								
									
										
										
										
											2018-02-02 14:59:31 -08:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								      // Otherwise look at the first child
							 | 
						
					
						
							
								
									
										
										
										
											2018-05-24 13:13:51 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								      nextNode = getChildLNode(node as LViewNode);
							 | 
						
					
						
							
								
									
										
										
										
											2018-01-25 15:32:21 +01:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    }
							 | 
						
					
						
							
								
									
										
										
										
											2018-02-02 14:59:31 -08:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							
								
									
										
										
										
											2018-07-03 20:04:36 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    if (nextNode === null) {
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								      nextNode = getNextLNode(node);
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								      // this last node was projected, we need to get back down to its projection node
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								      if (nextNode === null && (node.tNode.flags & TNodeFlags.isProjected)) {
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								        nextNode = getNextLNode(projectionNodeStack[projectionNodeIndex--] as LNode);
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								      }
							 | 
						
					
						
							
								
									
										
										
										
											2018-06-06 17:30:48 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								      /**
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								       * Find the next node in the LNode tree, taking into account the place where a node is
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								       * projected (in the shadow DOM) rather than where it comes from (in the light DOM).
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								       *
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								       * If there is no sibling node, then it goes to the next sibling of the parent node...
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								       * until it reaches rootNode (at which point null is returned).
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								       */
							 | 
						
					
						
							
								
									
										
										
										
											2018-07-03 20:04:36 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								      while (node && !nextNode) {
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								        node = getParentLNode(node);
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								        if (node === null || node === rootNode) return null;
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								        // When exiting a container, the beforeNode must be restored to the previous value
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								        if (!node.tNode.next && nodeType === TNodeType.Container) {
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								          beforeNode = node.native;
							 | 
						
					
						
							
								
									
										
										
										
											2018-06-06 17:30:48 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								        }
							 | 
						
					
						
							
								
									
										
										
										
											2018-07-03 20:04:36 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								        nextNode = getNextLNode(node);
							 | 
						
					
						
							
								
									
										
										
										
											2018-06-06 17:30:48 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								      }
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    }
							 | 
						
					
						
							
								
									
										
										
										
											2018-07-03 20:04:36 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    node = nextNode;
							 | 
						
					
						
							
								
									
										
										
										
											2018-06-06 17:30:48 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								  }
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								}
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							
								
									
										
										
										
											2018-07-03 20:04:36 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								/**
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								 * Given a current view, finds the nearest component's host (LElement).
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								 *
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								 * @param lViewData LViewData for which we want a host element node
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								 * @returns The host node
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								 */
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								export function findComponentHost(lViewData: LViewData): LElementNode {
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								  let viewRootLNode = lViewData[HOST_NODE];
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								  while (viewRootLNode.tNode.type === TNodeType.View) {
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    ngDevMode && assertDefined(lViewData[PARENT], 'lViewData.parent');
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    lViewData = lViewData[PARENT] !;
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    viewRootLNode = lViewData[HOST_NODE];
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								  }
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								  ngDevMode && assertNodeType(viewRootLNode, TNodeType.Element);
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								  ngDevMode && assertDefined(viewRootLNode.data, 'node.data');
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								  return viewRootLNode as LElementNode;
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								}
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							
								
									
										
										
										
											2018-06-06 17:30:48 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								/**
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								 * NOTE: for performance reasons, the possible actions are inlined within the function instead of
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								 * being passed as an argument.
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								 */
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								function executeNodeAction(
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    action: WalkLNodeTreeAction, renderer: Renderer3, parent: RElement | null,
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    node: RComment | RElement | RText, beforeNode?: RNode | null) {
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								  if (action === WalkLNodeTreeAction.Insert) {
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    isProceduralRenderer(renderer !) ?
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								        (renderer as ProceduralRenderer3).insertBefore(parent !, node, beforeNode as RNode | null) :
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								        parent !.insertBefore(node, beforeNode as RNode | null, true);
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								  } else if (action === WalkLNodeTreeAction.Detach) {
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    isProceduralRenderer(renderer !) ?
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								        (renderer as ProceduralRenderer3).removeChild(parent !, node) :
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								        parent !.removeChild(node);
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								  } else if (action === WalkLNodeTreeAction.Destroy) {
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    ngDevMode && ngDevMode.rendererDestroyNode++;
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    (renderer as ProceduralRenderer3).destroyNode !(node);
							 | 
						
					
						
							
								
									
										
										
										
											2018-01-25 15:32:21 +01:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								  }
							 | 
						
					
						
							
								
									
										
										
										
											2017-12-01 14:23:03 -08:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								}
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							
								
									
										
										
										
											2018-04-10 20:57:09 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								export function createTextNode(value: any, renderer: Renderer3): RText {
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								  return isProceduralRenderer(renderer) ? renderer.createText(stringify(value)) :
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								                                          renderer.createTextNode(stringify(value));
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								}
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							
								
									
										
										
										
											2017-12-13 11:04:46 -08:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								/**
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								 * Adds or removes all DOM elements associated with a view.
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								 *
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								 * Because some root nodes of the view may be containers, we sometimes need
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								 * to propagate deeply into the nested containers to remove all elements in the
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								 * views beneath it.
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								 *
							 | 
						
					
						
							
								
									
										
										
										
											2017-12-13 16:32:21 -08:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								 * @param container The container to which the root view belongs
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								 * @param rootNode The view from which elements should be added or removed
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								 * @param insertMode Whether or not elements should be added (if false, removing)
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								 * @param beforeNode The node before which elements should be added, if insert mode
							 | 
						
					
						
							
								
									
										
										
										
											2017-12-13 11:04:46 -08:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								 */
							 | 
						
					
						
							
								
									
										
										
										
											2017-12-01 14:23:03 -08:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								export function addRemoveViewFromContainer(
							 | 
						
					
						
							
								
									
										
										
										
											2018-01-08 20:17:13 -08:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    container: LContainerNode, rootNode: LViewNode, insertMode: true,
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    beforeNode: RNode | null): void;
							 | 
						
					
						
							
								
									
										
										
										
											2017-12-01 14:23:03 -08:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								export function addRemoveViewFromContainer(
							 | 
						
					
						
							
								
									
										
										
										
											2018-01-08 20:17:13 -08:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    container: LContainerNode, rootNode: LViewNode, insertMode: false): void;
							 | 
						
					
						
							
								
									
										
										
										
											2017-12-01 14:23:03 -08:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								export function addRemoveViewFromContainer(
							 | 
						
					
						
							
								
									
										
										
										
											2018-01-08 20:17:13 -08:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    container: LContainerNode, rootNode: LViewNode, insertMode: boolean,
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    beforeNode?: RNode | null): void {
							 | 
						
					
						
							
								
									
										
										
										
											2018-05-17 12:54:57 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								  ngDevMode && assertNodeType(container, TNodeType.Container);
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								  ngDevMode && assertNodeType(rootNode, TNodeType.View);
							 | 
						
					
						
							
								
									
										
										
										
											2018-06-07 22:42:32 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								  const parentNode = container.data[RENDER_PARENT];
							 | 
						
					
						
							
								
									
										
										
										
											2018-01-25 15:32:21 +01:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								  const parent = parentNode ? parentNode.native : null;
							 | 
						
					
						
							
								
									
										
										
										
											2017-12-01 14:23:03 -08:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								  if (parent) {
							 | 
						
					
						
							
								
									
										
										
										
											2018-05-31 15:45:46 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    let node: LNode|null = getChildLNode(rootNode);
							 | 
						
					
						
							
								
									
										
										
										
											2018-06-07 22:42:32 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    const renderer = container.view[RENDERER];
							 | 
						
					
						
							
								
									
										
										
										
											2018-05-31 15:45:46 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    walkLNodeTree(
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								        node, rootNode, insertMode ? WalkLNodeTreeAction.Insert : WalkLNodeTreeAction.Detach,
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								        renderer, parentNode, beforeNode);
							 | 
						
					
						
							
								
									
										
										
										
											2017-12-01 14:23:03 -08:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								  }
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								}
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								/**
							 | 
						
					
						
							
								
									
										
										
										
											2018-04-19 22:59:58 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								 * Traverses down and up the tree of views and containers to remove listeners and
							 | 
						
					
						
							
								
									
										
										
										
											2017-12-13 11:04:46 -08:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								 * call onDestroy callbacks.
							 | 
						
					
						
							
								
									
										
										
										
											2017-12-01 14:23:03 -08:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								 *
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								 * Notes:
							 | 
						
					
						
							
								
									
										
										
										
											2017-12-13 11:04:46 -08:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								 *  - Because it's used for onDestroy calls, it needs to be bottom-up.
							 | 
						
					
						
							
								
									
										
										
										
											2017-12-01 14:23:03 -08:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								 *  - Must process containers instead of their views to avoid splicing
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								 *  when views are destroyed and re-added.
							 | 
						
					
						
							
								
									
										
										
										
											2017-12-13 11:04:46 -08:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								 *  - Using a while loop because it's faster than recursion
							 | 
						
					
						
							
								
									
										
										
										
											2017-12-01 14:23:03 -08:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								 *  - Destroy only called on movement to sibling or movement to parent (laterally or up)
							 | 
						
					
						
							
								
									
										
										
										
											2017-12-13 11:04:46 -08:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								 *
							 | 
						
					
						
							
								
									
										
										
										
											2017-12-13 16:32:21 -08:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								 *  @param rootView The view to destroy
							 | 
						
					
						
							
								
									
										
										
										
											2017-12-01 14:23:03 -08:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								 */
							 | 
						
					
						
							
								
									
										
										
										
											2018-06-07 22:42:32 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								export function destroyViewTree(rootView: LViewData): void {
							 | 
						
					
						
							
								
									
										
										
										
											2018-05-30 13:43:14 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								  // If the view has no children, we can clean it up and return early.
							 | 
						
					
						
							
								
									
										
										
										
											2018-06-07 22:42:32 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								  if (rootView[TVIEW].childIndex === -1) {
							 | 
						
					
						
							
								
									
										
										
										
											2018-04-19 22:59:58 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    return cleanUpView(rootView);
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								  }
							 | 
						
					
						
							
								
									
										
										
										
											2018-06-07 22:42:32 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								  let viewOrContainer: LViewData|LContainer|null = getLViewChild(rootView);
							 | 
						
					
						
							
								
									
										
										
										
											2017-12-01 14:23:03 -08:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							
								
									
										
										
										
											2018-01-08 20:17:13 -08:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								  while (viewOrContainer) {
							 | 
						
					
						
							
								
									
										
										
										
											2018-06-07 22:42:32 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    let next: LViewData|LContainer|null = null;
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    if (viewOrContainer.length >= HEADER_OFFSET) {
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								      // If LViewData, traverse down to child.
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								      const view = viewOrContainer as LViewData;
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								      if (view[TVIEW].childIndex > -1) next = getLViewChild(view);
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    } else {
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								      // If container, traverse down to its first LViewData.
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								      const container = viewOrContainer as LContainer;
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								      if (container[VIEWS].length) next = container[VIEWS][0].data;
							 | 
						
					
						
							
								
									
										
										
										
											2017-12-01 14:23:03 -08:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    }
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    if (next == null) {
							 | 
						
					
						
							
								
									
										
										
										
											2018-06-07 22:42:32 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								      // Only clean up view when moving to the side or up, as destroy hooks
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								      // should be called in order from the bottom up.
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								      while (viewOrContainer && !viewOrContainer ![NEXT] && viewOrContainer !== rootView) {
							 | 
						
					
						
							
								
									
										
										
										
											2018-06-05 15:28:15 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								        cleanUpView(viewOrContainer);
							 | 
						
					
						
							
								
									
										
										
										
											2018-01-08 20:17:13 -08:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								        viewOrContainer = getParentState(viewOrContainer, rootView);
							 | 
						
					
						
							
								
									
										
										
										
											2017-12-01 14:23:03 -08:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								      }
							 | 
						
					
						
							
								
									
										
										
										
											2018-06-05 15:28:15 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								      cleanUpView(viewOrContainer || rootView);
							 | 
						
					
						
							
								
									
										
										
										
											2018-06-07 22:42:32 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								      next = viewOrContainer && viewOrContainer ![NEXT];
							 | 
						
					
						
							
								
									
										
										
										
											2017-12-01 14:23:03 -08:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    }
							 | 
						
					
						
							
								
									
										
										
										
											2018-01-08 20:17:13 -08:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    viewOrContainer = next;
							 | 
						
					
						
							
								
									
										
										
										
											2017-12-01 14:23:03 -08:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								  }
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								}
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							
								
									
										
										
										
											2017-12-13 11:04:46 -08:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								/**
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								 * Inserts a view into a container.
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								 *
							 | 
						
					
						
							
								
									
										
										
										
											2017-12-13 19:34:46 -08:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								 * This adds the view to the container's array of active views in the correct
							 | 
						
					
						
							
								
									
										
										
										
											2017-12-13 11:04:46 -08:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								 * position. It also adds the view's elements to the DOM if the container isn't a
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								 * root node of another view (in that case, the view's elements will be added when
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								 * the container's parent view is added later).
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								 *
							 | 
						
					
						
							
								
									
										
										
										
											2017-12-13 16:32:21 -08:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								 * @param container The container into which the view should be inserted
							 | 
						
					
						
							
								
									
										
										
										
											2018-05-11 20:57:37 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								 * @param viewNode The view to insert
							 | 
						
					
						
							
								
									
										
										
										
											2017-12-13 16:32:21 -08:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								 * @param index The index at which to insert the view
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								 * @returns The inserted view
							 | 
						
					
						
							
								
									
										
										
										
											2017-12-13 11:04:46 -08:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								 */
							 | 
						
					
						
							
								
									
										
										
										
											2018-01-08 20:17:13 -08:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								export function insertView(
							 | 
						
					
						
							
								
									
										
										
										
											2018-05-11 20:57:37 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    container: LContainerNode, viewNode: LViewNode, index: number): LViewNode {
							 | 
						
					
						
							
								
									
										
										
										
											2017-12-01 14:23:03 -08:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								  const state = container.data;
							 | 
						
					
						
							
								
									
										
										
										
											2018-06-07 22:42:32 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								  const views = state[VIEWS];
							 | 
						
					
						
							
								
									
										
										
										
											2018-06-26 11:39:56 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								  const lView = viewNode.data as LViewData;
							 | 
						
					
						
							
								
									
										
										
										
											2017-12-01 14:23:03 -08:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								  if (index > 0) {
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    // This is a new view, we need to add it to the children.
							 | 
						
					
						
							
								
									
										
										
										
											2018-06-26 11:39:56 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    views[index - 1].data[NEXT] = lView;
							 | 
						
					
						
							
								
									
										
										
										
											2017-12-01 14:23:03 -08:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								  }
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							
								
									
										
										
										
											2018-03-08 12:10:20 +01:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								  if (index < views.length) {
							 | 
						
					
						
							
								
									
										
										
										
											2018-06-26 11:39:56 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    lView[NEXT] = views[index].data;
							 | 
						
					
						
							
								
									
										
										
										
											2018-05-11 20:57:37 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    views.splice(index, 0, viewNode);
							 | 
						
					
						
							
								
									
										
										
										
											2018-03-08 12:10:20 +01:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								  } else {
							 | 
						
					
						
							
								
									
										
										
										
											2018-05-11 20:57:37 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    views.push(viewNode);
							 | 
						
					
						
							
								
									
										
										
										
											2018-06-26 11:39:56 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    lView[NEXT] = null;
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								  }
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								  // Dynamically inserted views need a reference to their parent container'S host so it's
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								  // possible to jump from a view to its container's next when walking the node tree.
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								  if (viewNode.tNode.index === -1) {
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    lView[CONTAINER_INDEX] = container.tNode.parent !.index;
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    (viewNode as{view: LViewData}).view = container.view;
							 | 
						
					
						
							
								
									
										
										
										
											2017-12-01 14:23:03 -08:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								  }
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							
								
									
										
										
										
											2018-05-28 11:57:36 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								  // Notify query that a new view has been added
							 | 
						
					
						
							
								
									
										
										
										
											2018-06-07 22:42:32 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								  if (lView[QUERIES]) {
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    lView[QUERIES] !.insertView(index);
							 | 
						
					
						
							
								
									
										
										
										
											2018-05-28 11:57:36 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								  }
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							
								
									
										
										
										
											2018-05-31 15:45:46 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								  // Sets the attached flag
							 | 
						
					
						
							
								
									
										
										
										
											2018-06-26 11:39:56 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								  lView[FLAGS] |= LViewFlags.Attached;
							 | 
						
					
						
							
								
									
										
										
										
											2018-05-31 15:45:46 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							
								
									
										
										
										
											2018-05-11 20:57:37 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								  return viewNode;
							 | 
						
					
						
							
								
									
										
										
										
											2017-12-01 14:23:03 -08:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								}
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							
								
									
										
										
										
											2017-12-13 11:04:46 -08:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								/**
							 | 
						
					
						
							
								
									
										
										
										
											2018-05-31 15:45:46 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								 * Detaches a view from a container.
							 | 
						
					
						
							
								
									
										
										
										
											2017-12-13 11:04:46 -08:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								 *
							 | 
						
					
						
							
								
									
										
										
										
											2017-12-13 19:34:46 -08:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								 * This method splices the view from the container's array of active views. It also
							 | 
						
					
						
							
								
									
										
										
										
											2018-05-31 15:45:46 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								 * removes the view's elements from the DOM.
							 | 
						
					
						
							
								
									
										
										
										
											2017-12-13 11:04:46 -08:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								 *
							 | 
						
					
						
							
								
									
										
										
										
											2018-05-31 15:45:46 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								 * @param container The container from which to detach a view
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								 * @param removeIndex The index of the view to detach
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								 * @returns The detached view
							 | 
						
					
						
							
								
									
										
										
										
											2017-12-13 11:04:46 -08:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								 */
							 | 
						
					
						
							
								
									
										
										
										
											2018-05-31 15:45:46 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								export function detachView(container: LContainerNode, removeIndex: number): LViewNode {
							 | 
						
					
						
							
								
									
										
										
										
											2018-06-07 22:42:32 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								  const views = container.data[VIEWS];
							 | 
						
					
						
							
								
									
										
										
										
											2017-12-13 19:34:46 -08:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								  const viewNode = views[removeIndex];
							 | 
						
					
						
							
								
									
										
										
										
											2017-12-01 14:23:03 -08:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								  if (removeIndex > 0) {
							 | 
						
					
						
							
								
									
										
										
										
											2018-06-07 22:42:32 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    views[removeIndex - 1].data[NEXT] = viewNode.data[NEXT] as LViewData;
							 | 
						
					
						
							
								
									
										
										
										
											2017-12-01 14:23:03 -08:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								  }
							 | 
						
					
						
							
								
									
										
										
										
											2017-12-13 19:34:46 -08:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								  views.splice(removeIndex, 1);
							 | 
						
					
						
							
								
									
										
										
										
											2018-06-18 16:55:43 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								  if (!container.tNode.detached) {
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    addRemoveViewFromContainer(container, viewNode, false);
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								  }
							 | 
						
					
						
							
								
									
										
										
										
											2017-12-01 14:23:03 -08:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								  // Notify query that view has been removed
							 | 
						
					
						
							
								
									
										
										
										
											2018-06-26 11:39:56 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								  const removedLView = viewNode.data;
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								  if (removedLView[QUERIES]) {
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    removedLView[QUERIES] !.removeView();
							 | 
						
					
						
							
								
									
										
										
										
											2018-05-28 11:57:36 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								  }
							 | 
						
					
						
							
								
									
										
										
										
											2018-06-26 11:39:56 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								  removedLView[CONTAINER_INDEX] = -1;
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								  (viewNode as{view: LViewData | null}).view = null;
							 | 
						
					
						
							
								
									
										
										
										
											2018-05-31 15:45:46 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								  // Unsets the attached flag
							 | 
						
					
						
							
								
									
										
										
										
											2018-06-07 22:42:32 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								  viewNode.data[FLAGS] &= ~LViewFlags.Attached;
							 | 
						
					
						
							
								
									
										
										
										
											2018-05-31 15:45:46 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								  return viewNode;
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								}
							 | 
						
					
						
							
								
									
										
										
										
											2018-05-28 11:57:36 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							
								
									
										
										
										
											2018-05-31 15:45:46 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								/**
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								 * Removes a view from a container, i.e. detaches it and then destroys the underlying LView.
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								 *
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								 * @param container The container from which to remove a view
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								 * @param removeIndex The index of the view to remove
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								 * @returns The removed view
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								 */
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								export function removeView(container: LContainerNode, removeIndex: number): LViewNode {
							 | 
						
					
						
							
								
									
										
										
										
											2018-06-07 22:42:32 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								  const viewNode = container.data[VIEWS][removeIndex];
							 | 
						
					
						
							
								
									
										
										
										
											2018-05-31 15:45:46 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								  detachView(container, removeIndex);
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								  destroyLView(viewNode.data);
							 | 
						
					
						
							
								
									
										
										
										
											2017-12-01 14:23:03 -08:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								  return viewNode;
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								}
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							
								
									
										
										
										
											2018-06-07 22:42:32 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								/** Gets the child of the given LViewData */
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								export function getLViewChild(viewData: LViewData): LViewData|LContainer|null {
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								  if (viewData[TVIEW].childIndex === -1) return null;
							 | 
						
					
						
							
								
									
										
										
										
											2018-05-30 13:43:14 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							
								
									
										
										
										
											2018-06-07 22:42:32 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								  const hostNode: LElementNode|LContainerNode = viewData[viewData[TVIEW].childIndex];
							 | 
						
					
						
							
								
									
										
										
										
											2018-05-30 13:43:14 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								  return hostNode.data ? hostNode.data : (hostNode.dynamicLContainerNode as LContainerNode).data;
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								}
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							
								
									
										
										
										
											2018-05-31 15:45:46 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								/**
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								 * A standalone function which destroys an LView,
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								 * conducting cleanup (e.g. removing listeners, calling onDestroys).
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								 *
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								 * @param view The view to be destroyed.
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								 */
							 | 
						
					
						
							
								
									
										
										
										
											2018-06-07 22:42:32 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								export function destroyLView(view: LViewData) {
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								  const renderer = view[RENDERER];
							 | 
						
					
						
							
								
									
										
										
										
											2018-05-31 15:45:46 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								  if (isProceduralRenderer(renderer) && renderer.destroyNode) {
							 | 
						
					
						
							
								
									
										
										
										
											2018-06-07 22:42:32 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    walkLNodeTree(view[HOST_NODE], view[HOST_NODE], WalkLNodeTreeAction.Destroy, renderer);
							 | 
						
					
						
							
								
									
										
										
										
											2018-05-31 15:45:46 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								  }
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								  destroyViewTree(view);
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								  // Sets the destroyed flag
							 | 
						
					
						
							
								
									
										
										
										
											2018-06-07 22:42:32 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								  view[FLAGS] |= LViewFlags.Destroyed;
							 | 
						
					
						
							
								
									
										
										
										
											2018-05-31 15:45:46 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								}
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							
								
									
										
										
										
											2017-12-13 11:04:46 -08:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								/**
							 | 
						
					
						
							
								
									
										
										
										
											2018-01-08 20:17:13 -08:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								 * Determines which LViewOrLContainer to jump to when traversing back up the
							 | 
						
					
						
							
								
									
										
										
										
											2017-12-13 11:04:46 -08:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								 * tree in destroyViewTree.
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								 *
							 | 
						
					
						
							
								
									
										
										
										
											2018-01-08 20:17:13 -08:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								 * Normally, the view's parent LView should be checked, but in the case of
							 | 
						
					
						
							
								
									
										
										
										
											2017-12-13 11:04:46 -08:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								 * embedded views, the container (which is the view node's parent, but not the
							 | 
						
					
						
							
								
									
										
										
										
											2018-01-08 20:17:13 -08:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								 * LView's parent) needs to be checked for a possible next property.
							 | 
						
					
						
							
								
									
										
										
										
											2017-12-13 11:04:46 -08:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								 *
							 | 
						
					
						
							
								
									
										
										
										
											2018-01-08 20:17:13 -08:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								 * @param state The LViewOrLContainer for which we need a parent state
							 | 
						
					
						
							
								
									
										
										
										
											2017-12-13 16:32:21 -08:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								 * @param rootView The rootView, so we don't propagate too far up the view tree
							 | 
						
					
						
							
								
									
										
										
										
											2018-01-08 20:17:13 -08:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								 * @returns The correct parent LViewOrLContainer
							 | 
						
					
						
							
								
									
										
										
										
											2017-12-13 11:04:46 -08:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								 */
							 | 
						
					
						
							
								
									
										
										
										
											2018-06-07 22:42:32 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								export function getParentState(state: LViewData | LContainer, rootView: LViewData): LViewData|
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    LContainer|null {
							 | 
						
					
						
							
								
									
										
										
										
											2017-12-01 14:23:03 -08:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								  let node;
							 | 
						
					
						
							
								
									
										
										
										
											2018-06-07 22:42:32 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								  if ((node = (state as LViewData) ![HOST_NODE]) && node.tNode.type === TNodeType.View) {
							 | 
						
					
						
							
								
									
										
										
										
											2017-12-01 14:23:03 -08:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    // if it's an embedded view, the state needs to go up to the container, in case the
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    // container has a next
							 | 
						
					
						
							
								
									
										
										
										
											2018-05-29 15:08:30 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    return getParentLNode(node) !.data as any;
							 | 
						
					
						
							
								
									
										
										
										
											2017-12-01 14:23:03 -08:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								  } else {
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    // otherwise, use parent view for containers or component views
							 | 
						
					
						
							
								
									
										
										
										
											2018-06-07 22:42:32 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    return state[PARENT] === rootView ? null : state[PARENT];
							 | 
						
					
						
							
								
									
										
										
										
											2017-12-01 14:23:03 -08:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								  }
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								}
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							
								
									
										
										
										
											2017-12-13 11:04:46 -08:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								/**
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								 * Removes all listeners and call all onDestroys in a given view.
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								 *
							 | 
						
					
						
							
								
									
										
										
										
											2018-06-07 22:42:32 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								 * @param view The LViewData to clean up
							 | 
						
					
						
							
								
									
										
										
										
											2017-12-13 11:04:46 -08:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								 */
							 | 
						
					
						
							
								
									
										
										
										
											2018-06-07 22:42:32 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								function cleanUpView(viewOrContainer: LViewData | LContainer): void {
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								  if ((viewOrContainer as LViewData)[TVIEW]) {
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    const view = viewOrContainer as LViewData;
							 | 
						
					
						
							
								
									
										
										
										
											2018-06-05 15:28:15 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    removeListeners(view);
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    executeOnDestroys(view);
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    executePipeOnDestroys(view);
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    // For component views only, the local renderer is destroyed as clean up time.
							 | 
						
					
						
							
								
									
										
										
										
											2018-06-07 22:42:32 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    if (view[TVIEW].id === -1 && isProceduralRenderer(view[RENDERER])) {
							 | 
						
					
						
							
								
									
										
										
										
											2018-06-05 15:28:15 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								      ngDevMode && ngDevMode.rendererDestroy++;
							 | 
						
					
						
							
								
									
										
										
										
											2018-06-07 22:42:32 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								      (view[RENDERER] as ProceduralRenderer3).destroy();
							 | 
						
					
						
							
								
									
										
										
										
											2018-06-05 15:28:15 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    }
							 | 
						
					
						
							
								
									
										
										
										
											2018-05-22 17:40:59 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								  }
							 | 
						
					
						
							
								
									
										
										
										
											2018-01-23 10:57:48 -08:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								}
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								/** Removes listeners and unsubscribes from output subscriptions */
							 | 
						
					
						
							
								
									
										
										
										
											2018-06-07 22:42:32 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								function removeListeners(viewData: LViewData): void {
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								  const cleanup = viewData[TVIEW].cleanup !;
							 | 
						
					
						
							
								
									
										
										
										
											2018-01-23 10:57:48 -08:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								  if (cleanup != null) {
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    for (let i = 0; i < cleanup.length - 1; i += 2) {
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								      if (typeof cleanup[i] === 'string') {
							 | 
						
					
						
							
								
									
										
										
										
											2018-06-05 15:28:15 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								        // This is a listener with the native renderer
							 | 
						
					
						
							
								
									
										
										
										
											2018-07-11 09:56:47 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								        const native = readElementValue(viewData[cleanup[i + 1]]).native;
							 | 
						
					
						
							
								
									
										
										
										
											2018-06-07 22:42:32 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								        const listener = viewData[CLEANUP] ![cleanup[i + 2]];
							 | 
						
					
						
							
								
									
										
										
										
											2018-06-05 15:28:15 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								        native.removeEventListener(cleanup[i], listener, cleanup[i + 3]);
							 | 
						
					
						
							
								
									
										
										
										
											2018-01-23 10:57:48 -08:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								        i += 2;
							 | 
						
					
						
							
								
									
										
										
										
											2018-06-05 15:28:15 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								      } else if (typeof cleanup[i] === 'number') {
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								        // This is a listener with renderer2 (cleanup fn can be found by index)
							 | 
						
					
						
							
								
									
										
										
										
											2018-06-07 22:42:32 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								        const cleanupFn = viewData[CLEANUP] ![cleanup[i]];
							 | 
						
					
						
							
								
									
										
										
										
											2018-06-05 15:28:15 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								        cleanupFn();
							 | 
						
					
						
							
								
									
										
										
										
											2018-01-23 10:57:48 -08:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								      } else {
							 | 
						
					
						
							
								
									
										
										
										
											2018-06-05 15:28:15 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								        // This is a cleanup function that is grouped with the index of its context
							 | 
						
					
						
							
								
									
										
										
										
											2018-06-07 22:42:32 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								        const context = viewData[CLEANUP] ![cleanup[i + 1]];
							 | 
						
					
						
							
								
									
										
										
										
											2018-06-05 15:28:15 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								        cleanup[i].call(context);
							 | 
						
					
						
							
								
									
										
										
										
											2018-01-23 10:57:48 -08:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								      }
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    }
							 | 
						
					
						
							
								
									
										
										
										
											2018-06-07 22:42:32 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    viewData[CLEANUP] = null;
							 | 
						
					
						
							
								
									
										
										
										
											2018-01-23 10:57:48 -08:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								  }
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								}
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								/** Calls onDestroy hooks for this view */
							 | 
						
					
						
							
								
									
										
										
										
											2018-06-07 22:42:32 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								function executeOnDestroys(view: LViewData): void {
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								  const tView = view[TVIEW];
							 | 
						
					
						
							
								
									
										
										
										
											2018-01-23 10:57:48 -08:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								  let destroyHooks: HookData|null;
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								  if (tView != null && (destroyHooks = tView.destroyHooks) != null) {
							 | 
						
					
						
							
								
									
										
										
										
											2018-06-07 22:42:32 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    callHooks(view[DIRECTIVES] !, destroyHooks);
							 | 
						
					
						
							
								
									
										
										
										
											2018-03-21 15:10:34 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								  }
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								}
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								/** Calls pipe destroy hooks for this view */
							 | 
						
					
						
							
								
									
										
										
										
											2018-06-07 22:42:32 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								function executePipeOnDestroys(viewData: LViewData): void {
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								  const pipeDestroyHooks = viewData[TVIEW] && viewData[TVIEW].pipeDestroyHooks;
							 | 
						
					
						
							
								
									
										
										
										
											2018-03-21 15:10:34 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								  if (pipeDestroyHooks) {
							 | 
						
					
						
							
								
									
										
										
										
											2018-06-07 22:42:32 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    callHooks(viewData !, pipeDestroyHooks);
							 | 
						
					
						
							
								
									
										
										
										
											2017-12-01 14:23:03 -08:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								  }
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								}
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							
								
									
										
										
										
											2017-12-13 11:04:46 -08:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								/**
							 | 
						
					
						
							
								
									
										
										
										
											2018-06-22 15:37:38 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								 * Returns whether a native element can be inserted into the given parent.
							 | 
						
					
						
							
								
									
										
										
										
											2018-06-26 11:39:56 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								 *
							 | 
						
					
						
							
								
									
										
										
										
											2018-06-22 15:37:38 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								 * There are two reasons why we may not be able to insert a element immediately.
							 | 
						
					
						
							
								
									
										
										
										
											2018-06-26 11:39:56 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								 * - Projection: When creating a child content element of a component, we have to skip the
							 | 
						
					
						
							
								
									
										
										
										
											2018-06-22 15:37:38 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								 *   insertion because the content of a component will be projected.
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								 *   `<component><content>delayed due to projection</content></component>`
							 | 
						
					
						
							
								
									
										
										
										
											2018-06-26 11:39:56 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								 * - Parent container is disconnected: This can happen when we are inserting a view into
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								 *   parent container, which itself is disconnected. For example the parent container is part
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								 *   of a View which has not be inserted or is mare for projection but has not been inserted
							 | 
						
					
						
							
								
									
										
										
										
											2018-06-22 15:37:38 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								 *   into destination.
							 | 
						
					
						
							
								
									
										
										
										
											2017-12-13 11:04:46 -08:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								 *
							 | 
						
					
						
							
								
									
										
										
										
											2018-06-22 15:37:38 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							
								
									
										
										
										
											2017-12-13 11:04:46 -08:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								 *
							 | 
						
					
						
							
								
									
										
										
										
											2018-06-22 15:37:38 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								 * @param parent The parent where the child will be inserted into.
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								 * @param currentView Current LView being processed.
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								 * @return boolean Whether the child should be inserted now (or delayed until later).
							 | 
						
					
						
							
								
									
										
										
										
											2017-12-13 11:04:46 -08:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								 */
							 | 
						
					
						
							
								
									
										
										
										
											2018-06-07 22:42:32 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								export function canInsertNativeNode(parent: LNode, currentView: LViewData): boolean {
							 | 
						
					
						
							
								
									
										
										
										
											2018-06-22 15:37:38 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								  // We can only insert into a Component or View. Any other type should be an Error.
							 | 
						
					
						
							
								
									
										
										
										
											2018-07-26 17:22:41 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								  ngDevMode && assertNodeOfPossibleTypes(
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								                   parent, TNodeType.Element, TNodeType.ElementContainer, TNodeType.View);
							 | 
						
					
						
							
								
									
										
										
										
											2018-06-22 15:37:38 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							
								
									
										
										
										
											2018-07-26 17:22:41 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								  if (parent.tNode.type === TNodeType.Element || parent.tNode.type === TNodeType.ElementContainer) {
							 | 
						
					
						
							
								
									
										
										
										
											2018-06-22 15:37:38 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    // Parent is an element.
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    if (parent.view !== currentView) {
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								      // If the Parent view is not the same as current view than we are inserting across
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								      // Views. This happens when we insert a root element of the component view into
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								      // the component host element and it should always be eager.
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								      return true;
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    }
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    // Parent elements can be a component which may have projection.
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    if (parent.data === null) {
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								      // Parent is a regular non-component element. We should eagerly insert into it
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								      // since we know that this relationship will never be broken.
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								      return true;
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    } else {
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								      // Parent is a Component. Component's content nodes are not inserted immediately
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								      // because they will be projected, and so doing insert at this point would be wasteful.
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								      // Since the projection would than move it to its final destination.
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								      return false;
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    }
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								  } else {
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    // Parent is a View.
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    ngDevMode && assertNodeType(parent, TNodeType.View);
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    // Because we are inserting into a `View` the `View` may be disconnected.
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    const grandParentContainer = getParentLNode(parent) as LContainerNode;
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    if (grandParentContainer == null) {
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								      // The `View` is not inserted into a `Container` we have to delay insertion.
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								      return false;
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    }
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    ngDevMode && assertNodeType(grandParentContainer, TNodeType.Container);
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    if (grandParentContainer.data[RENDER_PARENT] == null) {
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								      // The parent `Container` itself is disconnected. So we have to delay.
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								      return false;
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    } else {
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								      // The parent `Container` is in inserted state, so we can eagerly insert into
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								      // this location.
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								      return true;
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    }
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								  }
							 | 
						
					
						
							
								
									
										
										
										
											2018-01-26 11:36:31 +01:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								}
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								/**
							 | 
						
					
						
							
								
									
										
										
										
											2018-02-06 20:08:46 -08:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								 * Appends the `child` element to the `parent`.
							 | 
						
					
						
							
								
									
										
										
										
											2018-01-26 11:36:31 +01:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								 *
							 | 
						
					
						
							
								
									
										
										
										
											2018-06-18 16:55:43 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								 * The element insertion might be delayed {@link canInsertNativeNode}.
							 | 
						
					
						
							
								
									
										
										
										
											2018-01-26 11:36:31 +01:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								 *
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								 * @param parent The parent to which to append the child
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								 * @param child The child that should be appended
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								 * @param currentView The current LView
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								 * @returns Whether or not the child was appended
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								 */
							 | 
						
					
						
							
								
									
										
										
										
											2018-06-07 22:42:32 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								export function appendChild(parent: LNode, child: RNode | null, currentView: LViewData): boolean {
							 | 
						
					
						
							
								
									
										
										
										
											2018-01-26 11:36:31 +01:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								  if (child !== null && canInsertNativeNode(parent, currentView)) {
							 | 
						
					
						
							
								
									
										
										
										
											2018-06-07 22:42:32 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    const renderer = currentView[RENDERER];
							 | 
						
					
						
							
								
									
										
										
										
											2018-06-22 15:37:38 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    if (parent.tNode.type === TNodeType.View) {
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								      const container = getParentLNode(parent) as LContainerNode;
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								      const renderParent = container.data[RENDER_PARENT];
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								      const views = container.data[VIEWS];
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								      const index = views.indexOf(parent as LViewNode);
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								      const beforeNode =
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								          index + 1 < views.length ? (getChildLNode(views[index + 1]) !).native : container.native;
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								      isProceduralRenderer(renderer) ?
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								          renderer.insertBefore(renderParent !.native, child, beforeNode) :
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								          renderParent !.native.insertBefore(child, beforeNode, true);
							 | 
						
					
						
							
								
									
										
										
										
											2018-07-26 17:22:41 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    } else if (parent.tNode.type === TNodeType.ElementContainer) {
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								      const beforeNode = parent.native;
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								      const renderParent = getParentLNode(parent) as LElementNode;
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								      isProceduralRenderer(renderer) ?
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								          renderer.insertBefore(renderParent !.native, child, beforeNode) :
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								          renderParent !.native.insertBefore(child, beforeNode, true);
							 | 
						
					
						
							
								
									
										
										
										
											2018-06-22 15:37:38 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    } else {
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								      isProceduralRenderer(renderer) ? renderer.appendChild(parent.native !as RElement, child) :
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								                                       parent.native !.appendChild(child);
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    }
							 | 
						
					
						
							
								
									
										
										
										
											2017-12-01 14:23:03 -08:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    return true;
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								  }
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								  return false;
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								}
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							
								
									
										
										
										
											2018-06-18 16:55:43 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								/**
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								 * Removes the `child` element of the `parent` from the DOM.
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								 *
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								 * @param parent The parent from which to remove the child
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								 * @param child The child that should be removed
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								 * @param currentView The current LView
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								 * @returns Whether or not the child was removed
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								 */
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								export function removeChild(parent: LNode, child: RNode | null, currentView: LViewData): boolean {
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								  if (child !== null && canInsertNativeNode(parent, currentView)) {
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    // We only remove the element if not in View or not projected.
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    const renderer = currentView[RENDERER];
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    isProceduralRenderer(renderer) ? renderer.removeChild(parent.native as RElement, child) :
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								                                     parent.native !.removeChild(child);
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    return true;
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								  }
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								  return false;
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								}
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							
								
									
										
										
										
											2017-12-13 11:04:46 -08:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								/**
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								 * Appends a projected node to the DOM, or in the case of a projected container,
							 | 
						
					
						
							
								
									
										
										
										
											2018-01-26 11:36:31 +01:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								 * appends the nodes from all of the container's active views to the DOM.
							 | 
						
					
						
							
								
									
										
										
										
											2017-12-13 11:04:46 -08:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								 *
							 | 
						
					
						
							
								
									
										
										
										
											2017-12-13 16:32:21 -08:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								 * @param node The node to process
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								 * @param currentParent The last parent element to be processed
							 | 
						
					
						
							
								
									
										
										
										
											2018-01-08 20:17:13 -08:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								 * @param currentView Current LView
							 | 
						
					
						
							
								
									
										
										
										
											2017-12-13 11:04:46 -08:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								 */
							 | 
						
					
						
							
								
									
										
										
										
											2018-01-26 11:36:31 +01:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								export function appendProjectedNode(
							 | 
						
					
						
							
								
									
										
										
										
											2018-07-26 17:22:41 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    node: LElementNode | LElementContainerNode | LTextNode | LContainerNode,
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    currentParent: LElementNode | LElementContainerNode | LViewNode, currentView: LViewData,
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    renderParent: LElementNode): void {
							 | 
						
					
						
							
								
									
										
										
										
											2018-06-06 17:30:48 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								  appendChild(currentParent, node.native, currentView);
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								  if (node.tNode.type === TNodeType.Container) {
							 | 
						
					
						
							
								
									
										
										
										
											2018-06-27 16:05:23 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    // The node we are adding is a container and we are adding it to an element which
							 | 
						
					
						
							
								
									
										
										
										
											2017-12-08 11:48:54 -08:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    // is not a component (no more re-projection).
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    // Alternatively a container is projected at the root of a component's template
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    // and can't be re-projected (as not content of any component).
							 | 
						
					
						
							
								
									
										
										
										
											2018-06-27 16:05:23 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    // Assign the final projection location in those cases.
							 | 
						
					
						
							
								
									
										
										
										
											2018-01-08 20:17:13 -08:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    const lContainer = (node as LContainerNode).data;
							 | 
						
					
						
							
								
									
										
										
										
											2018-06-27 16:05:23 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    lContainer[RENDER_PARENT] = renderParent;
							 | 
						
					
						
							
								
									
										
										
										
											2018-06-07 22:42:32 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    const views = lContainer[VIEWS];
							 | 
						
					
						
							
								
									
										
										
										
											2017-12-01 14:23:03 -08:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    for (let i = 0; i < views.length; i++) {
							 | 
						
					
						
							
								
									
										
										
										
											2018-06-29 16:44:54 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								      addRemoveViewFromContainer(node as LContainerNode, views[i], true, node.native);
							 | 
						
					
						
							
								
									
										
										
										
											2017-12-01 14:23:03 -08:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    }
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								  }
							 | 
						
					
						
							
								
									
										
										
										
											2018-04-09 17:35:50 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								  if (node.dynamicLContainerNode) {
							 | 
						
					
						
							
								
									
										
										
										
											2018-06-27 16:05:23 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    node.dynamicLContainerNode.data[RENDER_PARENT] = renderParent;
							 | 
						
					
						
							
								
									
										
										
										
											2018-06-06 17:30:48 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    appendChild(currentParent, node.dynamicLContainerNode.native, currentView);
							 | 
						
					
						
							
								
									
										
										
										
											2018-04-09 17:35:50 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								  }
							 | 
						
					
						
							
								
									
										
										
										
											2017-12-01 14:23:03 -08:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								}
							 |