@@ -54,7 +54,7 @@ class LoopNode extends Node {
5454 */
5555 constructor ( params = [ ] ) {
5656
57- super ( ) ;
57+ super ( 'void' ) ;
5858
5959 this . params = params ;
6060
@@ -100,16 +100,20 @@ class LoopNode extends Node {
100100
101101 }
102102
103- const stack = builder . addStack ( ) ; // TODO: cache() it
103+ const stack = builder . addStack ( ) ;
104104
105- properties . returnsNode = this . params [ this . params . length - 1 ] ( inputs , builder ) ;
105+ const fnCall = this . params [ this . params . length - 1 ] ( inputs ) ;
106+
107+ properties . returnsNode = fnCall . context ( { nodeLoop : fnCall } ) ;
106108 properties . stackNode = stack ;
107109
108110 const baseParam = this . params [ 0 ] ;
109111
110112 if ( baseParam . isNode !== true && typeof baseParam . update === 'function' ) {
111113
112- properties . updateNode = Fn ( this . params [ 0 ] . update ) ( inputs ) ;
114+ const fnUpdateCall = Fn ( this . params [ 0 ] . update ) ( inputs ) ;
115+
116+ properties . updateNode = fnUpdateCall . context ( { nodeLoop : fnUpdateCall } ) ;
113117
114118 }
115119
@@ -119,20 +123,6 @@ class LoopNode extends Node {
119123
120124 }
121125
122- /**
123- * This method is overwritten since the node type is inferred based on the loop configuration.
124- *
125- * @param {NodeBuilder } builder - The current node builder.
126- * @return {string } The node type.
127- */
128- getNodeType ( builder ) {
129-
130- const { returnsNode } = this . getProperties ( builder ) ;
131-
132- return returnsNode ? returnsNode . getNodeType ( builder ) : 'void' ;
133-
134- }
135-
136126 setup ( builder ) {
137127
138128 // setup properties
@@ -312,7 +302,7 @@ class LoopNode extends Node {
312302
313303 const stackSnippet = stackNode . build ( builder , 'void' ) ;
314304
315- const returnsSnippet = properties . returnsNode ? properties . returnsNode . build ( builder ) : '' ;
305+ properties . returnsNode . build ( builder , 'void' ) ;
316306
317307 builder . removeFlowTab ( ) . addFlowCode ( '\n' + builder . tab + stackSnippet ) ;
318308
@@ -324,8 +314,6 @@ class LoopNode extends Node {
324314
325315 builder . addFlowTab ( ) ;
326316
327- return returnsSnippet ;
328-
329317 }
330318
331319}
0 commit comments