Skip to content

Commit aa370f4

Browse files
authored
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
1 parent b1fd13b commit aa370f4

File tree

2 files changed

+19
-7
lines changed

2 files changed

+19
-7
lines changed

src/nodes/core/Node.js

Lines changed: 18 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -474,8 +474,9 @@ class Node extends EventDispatcher {
474474

475475
}
476476

477-
// return a outputNode if exists
478-
return null;
477+
// return a outputNode if exists or null
478+
479+
return nodeProperties.outputNode || null;
479480

480481
}
481482

@@ -609,17 +610,19 @@ class Node extends EventDispatcher {
609610

610611
if ( properties.initialized !== true ) {
611612

612-
const stackNodesBeforeSetup = builder.stack.nodes.length;
613+
//const stackNodesBeforeSetup = builder.stack.nodes.length;
613614

614615
properties.initialized = true;
615-
properties.outputNode = this.setup( builder );
616616

617-
if ( properties.outputNode !== null && builder.stack.nodes.length !== stackNodesBeforeSetup ) {
617+
const outputNode = this.setup( builder ); // return a node or null
618+
const isNodeOutput = outputNode && outputNode.isNode === true;
619+
620+
/*if ( isNodeOutput && builder.stack.nodes.length !== stackNodesBeforeSetup ) {
618621
619622
// !! no outputNode !!
620-
//properties.outputNode = builder.stack;
623+
//outputNode = builder.stack;
621624
622-
}
625+
}*/
623626

624627
for ( const childNode of Object.values( properties ) ) {
625628

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

632635
}
633636

637+
if ( isNodeOutput ) {
638+
639+
outputNode.build( builder );
640+
641+
}
642+
643+
properties.outputNode = outputNode;
644+
634645
}
635646

636647
} else if ( buildStage === 'analyze' ) {

src/nodes/core/NodeBuilder.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -678,6 +678,7 @@ class NodeBuilder {
678678
/**
679679
* It is used to add Nodes that will be used as FRAME and RENDER events,
680680
* and need to follow a certain sequence in the calls to work correctly.
681+
* This function should be called after 'setup()' in the 'build()' process to ensure that the child nodes are processed first.
681682
*
682683
* @param {Node} node - The node to add.
683684
*/

0 commit comments

Comments
 (0)