@@ -93,7 +93,7 @@ import { ngObserveDirective } from "../../directive/observe/observe.js";
9393/**
9494 * @typedef {Object } LinkFnMapping
9595 * @property {number } index
96- * @property {NodeLinkFn } [nodeLinkFn ]
96+ * @property {NodeLinkFnCtx } [nodeLinkFnCtx ]
9797 * @property {CompositeLinkFn } [childLinkFn]
9898 */
9999
@@ -109,6 +109,11 @@ import { ngObserveDirective } from "../../directive/observe/observe.js";
109109/**
110110 * @typedef {Object } NodeLinkFnCtx
111111 * @property {NodeLinkFn } nodeLinkFn
112+ * @property {boolean } terminal
113+ * @property {TranscludeFn } transclude
114+ * @property {boolean } transcludeOnThisElement
115+ * @property {boolean } templateOnThisElement
116+ * @property {boolean } newScope
112117 */
113118
114119/**
@@ -846,12 +851,11 @@ export class CompileProvider {
846851 ignoreDirective ,
847852 ) ;
848853
849- // /** @type {NodeLinkFnCtx } */
850- // let nodeLinkFnCtx;
851- /** @type {NodeLinkFn } */
852- let nodeLinkFn ;
854+ /** @type {NodeLinkFnCtx } */
855+ let nodeLinkFnCtx ;
856+
853857 if ( directives . length ) {
854- nodeLinkFn = applyDirectivesToNode (
858+ nodeLinkFnCtx = applyDirectivesToNode (
855859 directives ,
856860 nodeRefList . getIndex ( i ) ,
857861 attrs ,
@@ -865,24 +869,22 @@ export class CompileProvider {
865869 ctxNodeRef : nodeRefList ,
866870 } ) ,
867871 ) ;
868- } else {
869- nodeLinkFn = null ;
870872 }
871873
872874 let childLinkFn ;
873875 let childNodes ;
874-
876+ let nodeLinkFn = nodeLinkFnCtx ?. nodeLinkFn ;
875877 if (
876- ( nodeLinkFn && nodeLinkFn [ " terminal" ] ) ||
878+ ( nodeLinkFn && nodeLinkFnCtx . terminal ) ||
877879 ! ( childNodes = nodeRefList . getIndex ( i ) . childNodes ) ||
878880 ! childNodes . length
879881 ) {
880882 childLinkFn = null ;
881883 } else {
882884 let transcluded = nodeLinkFn
883- ? ( nodeLinkFn [ " transcludeOnThisElement" ] ||
884- ! nodeLinkFn [ " templateOnThisElement" ] ) &&
885- nodeLinkFn [ " transclude" ]
885+ ? ( nodeLinkFnCtx . transcludeOnThisElement ||
886+ ! nodeLinkFnCtx . templateOnThisElement ) &&
887+ nodeLinkFnCtx . transclude
886888 : transcludeFn ;
887889 // recursive call
888890 const childNodeRef = new NodeRef ( childNodes ) ;
@@ -892,7 +894,7 @@ export class CompileProvider {
892894 if ( nodeLinkFn || childLinkFn ) {
893895 linkFnsList . push ( {
894896 index : i ,
895- nodeLinkFn : nodeLinkFn ,
897+ nodeLinkFnCtx : nodeLinkFnCtx ,
896898 childLinkFn : childLinkFn ,
897899 } ) ;
898900 linkFnFound = true ;
@@ -941,24 +943,24 @@ export class CompileProvider {
941943 }
942944 }
943945
944- linkFnsList . forEach ( ( { index, nodeLinkFn , childLinkFn } ) => {
946+ linkFnsList . forEach ( ( { index, nodeLinkFnCtx , childLinkFn } ) => {
945947 const node = stableNodeList [ index ] ;
946948 node . stable = true ;
947949 let childScope ;
948950 let childBoundTranscludeFn ;
949951
950- if ( nodeLinkFn ) {
951- childScope = nodeLinkFn [ "scope" ] ? scope . $new ( ) : scope ;
952+ if ( nodeLinkFnCtx ?. nodeLinkFn ) {
953+ childScope = nodeLinkFnCtx . newScope ? scope . $new ( ) : scope ;
952954
953- if ( nodeLinkFn [ " transcludeOnThisElement" ] ) {
955+ if ( nodeLinkFnCtx . transcludeOnThisElement ) {
954956 // bind proper scope for the translusion function
955957 childBoundTranscludeFn = createBoundTranscludeFn (
956958 scope ,
957- nodeLinkFn [ " transclude" ] ,
959+ nodeLinkFnCtx . transclude ,
958960 parentBoundTranscludeFn ,
959961 ) ;
960962 } else if (
961- ! nodeLinkFn [ " templateOnThisElement" ] &&
963+ ! nodeLinkFnCtx . templateOnThisElement &&
962964 parentBoundTranscludeFn
963965 ) {
964966 childBoundTranscludeFn = parentBoundTranscludeFn ;
@@ -972,11 +974,11 @@ export class CompileProvider {
972974 }
973975
974976 // attach new scope to element
975- if ( nodeLinkFn [ "scope" ] ) {
977+ if ( nodeLinkFnCtx ?. newScope ) {
976978 setScope ( node , childScope ) ;
977979 }
978980 // @ts -ignore
979- nodeLinkFn (
981+ nodeLinkFnCtx . nodeLinkFn (
980982 // @ts -ignore
981983 childLinkFn ,
982984 childScope ,
@@ -1235,7 +1237,7 @@ export class CompileProvider {
12351237 * @param {Array.<Function> } [postLinkFns]
12361238 * @param {Object } [previousCompileContext] Context used for previous compilation of the current
12371239 * node
1238- * @returns {NodeLinkFn } node link function
1240+ * @returns {NodeLinkFnCtx } node link function
12391241 */
12401242 function applyDirectivesToNode (
12411243 directives ,
@@ -1250,6 +1252,7 @@ export class CompileProvider {
12501252 previousCompileContext = previousCompileContext || { } ;
12511253
12521254 let terminalPriority = - Number . MAX_VALUE ;
1255+ let terminal = false ;
12531256 let {
12541257 newScopeDirective,
12551258 controllerDirectives,
@@ -1982,24 +1985,23 @@ export class CompileProvider {
19821985 }
19831986
19841987 if ( directive . terminal ) {
1985- nodeLinkFn [ " terminal" ] = true ;
1988+ terminal = true ;
19861989 terminalPriority = Math . max ( terminalPriority , directive . priority ) ;
19871990 }
19881991 }
19891992
1990- nodeLinkFn [ "scope" ] =
1991- newScopeDirective && newScopeDirective . scope === true ;
1992-
1993- // track trancluded scope
1994- nodeLinkFn [ "transcludeOnThisElement" ] = hasTranscludeDirective ;
1995- nodeLinkFn [ "templateOnThisElement" ] = hasTemplate ;
1996- nodeLinkFn [ "transclude" ] = childTranscludeFn ;
1997-
19981993 previousCompileContext . hasElementTranscludeDirective =
19991994 hasElementTranscludeDirective ;
20001995
20011996 // might be normal or delayed nodeLinkFn depending on if templateUrl is present
2002- return nodeLinkFn ;
1997+ return {
1998+ nodeLinkFn,
1999+ terminal,
2000+ transclude : childTranscludeFn ,
2001+ transcludeOnThisElement : hasTranscludeDirective ,
2002+ templateOnThisElement : hasTemplate ,
2003+ newScope : newScopeDirective && newScopeDirective . scope === true ,
2004+ } ;
20032005
20042006 /// /////////////////
20052007 function addLinkFns ( pre , post ) {
@@ -2303,6 +2305,7 @@ export class CompileProvider {
23032305 /** @type {any } */
23042306 let afterTemplateNodeLinkFn ;
23052307 let afterTemplateChildLinkFn ;
2308+ let afterTemplateNodeLinkFnCtx ;
23062309 const beforeTemplateCompileNode = $compileNode . getAny ( ) ;
23072310 const origAsyncDirective = directives . shift ( ) ;
23082311 const derivedSyncDirective = inherit ( origAsyncDirective , {
@@ -2388,7 +2391,7 @@ export class CompileProvider {
23882391 }
23892392
23902393 directives . unshift ( derivedSyncDirective ) ;
2391- afterTemplateNodeLinkFn = applyDirectivesToNode (
2394+ afterTemplateNodeLinkFnCtx = applyDirectivesToNode (
23922395 directives ,
23932396 compileNode ,
23942397 tAttrs ,
@@ -2398,6 +2401,8 @@ export class CompileProvider {
23982401 postLinkFns ,
23992402 { ...previousCompileContext , ctxNodeRef : $compileNode } ,
24002403 ) ;
2404+
2405+ afterTemplateNodeLinkFn = afterTemplateNodeLinkFnCtx ?. nodeLinkFn ;
24012406 if ( $rootElement ) {
24022407 Object . entries ( $rootElement ) . forEach ( ( [ i , node ] ) => {
24032408 if ( node === compileNode ) {
@@ -2445,10 +2450,10 @@ export class CompileProvider {
24452450 // SVG element, where class name is read-only.
24462451 }
24472452 }
2448- if ( afterTemplateNodeLinkFn . transcludeOnThisElement ) {
2453+ if ( afterTemplateNodeLinkFnCtx . transcludeOnThisElement ) {
24492454 childBoundTranscludeFn = createBoundTranscludeFn (
24502455 scope ,
2451- afterTemplateNodeLinkFn . transclude ,
2456+ afterTemplateNodeLinkFnCtx . transclude ,
24522457 boundTranscludeFn ,
24532458 ) ;
24542459 } else {
0 commit comments