Skip to content

Commit

Permalink
Node: Ensure that the child nodes are processed first for events (#30228
Browse files Browse the repository at this point in the history
)

* ensure that the child nodes are processed first

* cleanup

* Update Node.js

* Update Node.js

* cleanup

* Update Node.js
  • Loading branch information
sunag authored Dec 30, 2024
1 parent b1fd13b commit aa370f4
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 7 deletions.
25 changes: 18 additions & 7 deletions src/nodes/core/Node.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;

}

Expand Down Expand Up @@ -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 ) ) {

Expand All @@ -631,6 +634,14 @@ class Node extends EventDispatcher {

}

if ( isNodeOutput ) {

outputNode.build( builder );

}

properties.outputNode = outputNode;

}

} else if ( buildStage === 'analyze' ) {
Expand Down
1 change: 1 addition & 0 deletions src/nodes/core/NodeBuilder.js
Original file line number Diff line number Diff line change
Expand Up @@ -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.
*/
Expand Down

0 comments on commit aa370f4

Please sign in to comment.