Skip to content

Commit

Permalink
don't process too early, just don't set the function prop to true if …
Browse files Browse the repository at this point in the history
…we have a process function
  • Loading branch information
hannojg committed Jan 30, 2025
1 parent 12b2e7d commit 11eb8f8
Showing 1 changed file with 9 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -294,23 +294,15 @@ function diffProperties(
prevProp = prevProps[propKey];
nextProp = nextProps[propKey];

if (typeof nextProp === 'function') {
if (typeof attributeConfig === 'object') {
// When the config for a function prop has a custom process method
// we don't assume its a regular event handler, but use the process method:
nextProp = attributeConfig.process(nextProp);
if (typeof prevProp === 'function') {
prevProp = attributeConfig.process(prevProp);
}
} else {
// functions are converted to booleans as markers that the associated
// events should be sent from native.
nextProp = (true: any);
// If nextProp is not a function, then don't bother changing prevProp
// since nextProp will win and go into the updatePayload regardless.
if (typeof prevProp === 'function') {
prevProp = (true: any);
}
const attributeConfigHasProcess = typeof attributeConfig === 'object' && typeof attributeConfig.process === 'function';
if (typeof nextProp === 'function' && !attributeConfigHasProcess) {
// functions are converted to booleans as markers that the associated
// events should be sent from native.
nextProp = (true: any);
// If nextProp is not a function, then don't bother changing prevProp
// since nextProp will win and go into the updatePayload regardless.
if (typeof prevProp === 'function') {
prevProp = (true: any);
}
}

Expand Down

0 comments on commit 11eb8f8

Please sign in to comment.