Преглед изворни кода

Node: Ensure that the child nodes are processed first for events (#30228)

* ensure that the child nodes are processed first

* cleanup

* Update Node.js

* Update Node.js

* cleanup

* Update Node.js
sunag пре 1 година
родитељ
комит
aa370f4ff3
2 измењених фајлова са 19 додато и 7 уклоњено
  1. 18 7
      src/nodes/core/Node.js
  2. 1 0
      src/nodes/core/NodeBuilder.js

+ 18 - 7
src/nodes/core/Node.js

@@ -474,8 +474,9 @@ class Node extends EventDispatcher {
 
 		}
 
-		// return a outputNode if exists
-		return null;
+		// return a outputNode if exists or null
+
+		return nodeProperties.outputNode || null;
 
 	}
 
@@ -609,17 +610,19 @@ class Node extends EventDispatcher {
 
 			if ( properties.initialized !== true ) {
 
-				const stackNodesBeforeSetup = builder.stack.nodes.length;
+				//const stackNodesBeforeSetup = builder.stack.nodes.length;
 
 				properties.initialized = true;
-				properties.outputNode = this.setup( builder );
 
-				if ( properties.outputNode !== null && builder.stack.nodes.length !== stackNodesBeforeSetup ) {
+				const outputNode = this.setup( builder ); // return a node or null
+				const isNodeOutput = outputNode && outputNode.isNode === true;
+
+				/*if ( isNodeOutput && builder.stack.nodes.length !== stackNodesBeforeSetup ) {
 
 					// !! no outputNode !!
-					//properties.outputNode = builder.stack;
+					//outputNode = builder.stack;
 
-				}
+				}*/
 
 				for ( const childNode of Object.values( properties ) ) {
 
@@ -631,6 +634,14 @@ class Node extends EventDispatcher {
 
 				}
 
+				if ( isNodeOutput ) {
+
+					outputNode.build( builder );
+
+				}
+
+				properties.outputNode = outputNode;
+
 			}
 
 		} else if ( buildStage === 'analyze' ) {

+ 1 - 0
src/nodes/core/NodeBuilder.js

@@ -678,6 +678,7 @@ class NodeBuilder {
 	/**
 	 * It is used to add Nodes that will be used as FRAME and RENDER events,
 	 * and need to follow a certain sequence in the calls to work correctly.
+	 * This function should be called after 'setup()' in the 'build()' process to ensure that the child nodes are processed first.
 	 *
 	 * @param {Node} node - The node to add.
 	 */

粤ICP备19079148号