@@ -37,7 +37,7 @@ import {SanitizerFn} from './interfaces/sanitization';
37
37
import { StylingContext } from './interfaces/styling' ;
38
38
import { BINDING_INDEX , CHILD_HEAD , CHILD_TAIL , CLEANUP , CONTEXT , DECLARATION_VIEW , ExpandoInstructions , FLAGS , HEADER_OFFSET , HOST , INJECTOR , InitPhaseState , LView , LViewFlags , NEXT , OpaqueViewState , PARENT , QUERIES , RENDERER , RENDERER_FACTORY , RootContext , RootContextFlags , SANITIZER , TData , TVIEW , TView , T_HOST } from './interfaces/view' ;
39
39
import { assertNodeOfPossibleTypes , assertNodeType } from './node_assert' ;
40
- import { appendChild , appendProjectedNode , createTextNode , insertView , removeView } from './node_manipulation' ;
40
+ import { appendChild , appendProjectedNodes , createTextNode , insertView , removeView } from './node_manipulation' ;
41
41
import { isNodeMatchingSelectorList , matchingSelectorIndex } from './node_selector_matcher' ;
42
42
import { applyOnCreateInstructions } from './node_util' ;
43
43
import { decreaseElementDepthCount , enterView , getBindingsEnabled , getCheckNoChangesMode , getContextLView , getCurrentDirectiveDef , getElementDepthCount , getIsParent , getLView , getPreviousOrParentTNode , increaseElementDepthCount , isCreationMode , leaveView , nextContextImpl , resetComponentState , setBindingRoot , setCheckNoChangesMode , setCurrentDirectiveDef , setCurrentQueryIndex , setIsParent , setPreviousOrParentTNode } from './state' ;
@@ -2625,14 +2625,6 @@ export function projectionDef(selectors?: CssSelectorList[], textSelectors?: str
2625
2625
}
2626
2626
}
2627
2627
2628
- /**
2629
- * Stack used to keep track of projection nodes in projection() instruction.
2630
- *
2631
- * This is deliberately created outside of projection() to avoid allocating
2632
- * a new array each time the function is called. Instead the array will be
2633
- * re-used by each invocation. This works because the function is not reentrant.
2634
- */
2635
- const projectionNodeStack : ( LView | TNode ) [ ] = [ ] ;
2636
2628
2637
2629
/**
2638
2630
* Inserts previously re-distributed projected nodes. This instruction must be preceded by a call
@@ -2655,52 +2647,7 @@ export function projection(nodeIndex: number, selectorIndex: number = 0, attrs?:
2655
2647
setIsParent ( false ) ;
2656
2648
2657
2649
// re-distribution of projectable nodes is stored on a component's view level
2658
- const componentView = findComponentView ( lView ) ;
2659
- const componentNode = componentView [ T_HOST ] as TElementNode ;
2660
- let nodeToProject = ( componentNode . projection as ( TNode | null ) [ ] ) [ selectorIndex ] ;
2661
- let projectedView = componentView [ PARENT ] ! as LView ;
2662
- ngDevMode && assertLView ( projectedView ) ;
2663
- let projectionNodeIndex = - 1 ;
2664
-
2665
- if ( Array . isArray ( nodeToProject ) ) {
2666
- appendChild ( nodeToProject , tProjectionNode , lView ) ;
2667
- } else {
2668
- while ( nodeToProject ) {
2669
- if ( nodeToProject . type === TNodeType . Projection ) {
2670
- // This node is re-projected, so we must go up the tree to get its projected nodes.
2671
- const currentComponentView = findComponentView ( projectedView ) ;
2672
- const currentComponentHost = currentComponentView [ T_HOST ] as TElementNode ;
2673
- const firstProjectedNode = ( currentComponentHost . projection as (
2674
- TNode | null ) [ ] ) [ nodeToProject . projection as number ] ;
2675
-
2676
- if ( firstProjectedNode ) {
2677
- if ( Array . isArray ( firstProjectedNode ) ) {
2678
- appendChild ( firstProjectedNode , tProjectionNode , lView ) ;
2679
- } else {
2680
- projectionNodeStack [ ++ projectionNodeIndex ] = nodeToProject ;
2681
- projectionNodeStack [ ++ projectionNodeIndex ] = projectedView ;
2682
-
2683
- nodeToProject = firstProjectedNode ;
2684
- projectedView = getLViewParent ( currentComponentView ) ! ;
2685
- continue ;
2686
- }
2687
- }
2688
- } else {
2689
- // This flag must be set now or we won't know that this node is projected
2690
- // if the nodes are inserted into a container later.
2691
- nodeToProject . flags |= TNodeFlags . isProjected ;
2692
- appendProjectedNode ( nodeToProject , tProjectionNode , lView , projectedView ) ;
2693
- }
2694
-
2695
- // If we are finished with a list of re-projected nodes, we need to get
2696
- // back to the root projection node that was re-projected.
2697
- if ( nodeToProject . next === null && projectedView !== componentView [ PARENT ] ! ) {
2698
- projectedView = projectionNodeStack [ projectionNodeIndex -- ] as LView ;
2699
- nodeToProject = projectionNodeStack [ projectionNodeIndex -- ] as TNode ;
2700
- }
2701
- nodeToProject = nodeToProject . next ;
2702
- }
2703
- }
2650
+ appendProjectedNodes ( lView , tProjectionNode , selectorIndex , findComponentView ( lView ) ) ;
2704
2651
}
2705
2652
2706
2653
/**
0 commit comments