Skip to content

Commit 1551d46

Browse files
committed
Update data properties with incoming data fully before calling hydrate events.
1 parent 88c52bc commit 1551d46

File tree

1 file changed

+11
-4
lines changed

1 file changed

+11
-4
lines changed

models/Component.cfc

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -703,12 +703,19 @@ component output="true" {
703703
// Set our component's id to the incoming memo id
704704
variables._id = arguments.componentPayload.snapshot.memo.id;
705705
// Append the incoming data to our component's data
706+
// It important that we run through all the incoming snapshot
707+
// data and set it to our component's data before calling
708+
// the onHydrate events.
706709
arguments.componentPayload.snapshot.data.each( function( key, value ) {
707-
variables.data[ key ] = value;
708-
if ( structKeyExists( this, "onHydrate#key#") ) {
709-
invoke( this, "onHydrate#key#", { value: value });
710-
}
710+
variables.data[ arguments.key ] = arguments.value;
711+
} );
712+
// Run onHydrateProperty events
713+
arguments.componentPayload.snapshot.data.filter( function( key, value ) {
714+
return structKeyExists( this, "onHydrate#arguments.key#" );
715+
} ).each( function( key, value ) {
716+
invoke( this, "onHydrate#arguments.key#" );
711717
} );
718+
712719
// Run onHydrate if it exists
713720
if ( structKeyExists( this, "onHydrate" ) ) {
714721
invoke( this, "onHydrate", { incomingPayload: arguments.componentPayload.snapshot.data } );

0 commit comments

Comments
 (0)