GeezerVisonThe World Wide Web, restored to 800 pixels of glory. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Home|About|Gaming cabinet|Archives|How it works|Starter sites | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
GeezerVison is showing github.com — Clean up fastAddProperties and make it more correct by dmytrorykun · Pull Request #29015 · react/react ConversationSummaryThis PR makes some fixes to the
How did you test this change?Build and run RNTester app.
Sorry, something went wrong. Uh oh!
There was an error while loading. Please reload this page. All reactions
|
There was an error while loading. Please reload this page.
|
Comparing: 7039834...fbcbb40 Critical size changesIncludes critical production bundles, as well as any change greater than 2%:
Significant size changesIncludes any change greater than 0.2%: Expand to show
|
Sorry, something went wrong.
There was an error while loading. Please reload this page.
| attributeConfig = validAttributes[propKey]; | ||
|
|
||
| if (attributeConfig === undefined) { | ||
| if (!attributeConfig) { | ||
| continue; | ||
| } |
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
What I was just mentioning about: we could change the default here and stop ignoring any properties that do not have validAttributes entry.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
That requires the new parser, no? Otherwise, we might get a native exception.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Update native to ignore unknown props?
This would take us a step closer to removing Static View Configs. We would need this, and a way to specify the bubbling behavior of events. Or we could convert all custom events to be direct, and store a config for which built-in events should bubble (which would also fix the bubbing/direct event name collision bug).
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Update native to ignore unknown props?
This would take us a step closer to removing Static View Configs.
That is already planned!
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Consider unit tests, since this logic seems quite nuanced. It's be a good way to also compare the old and new code paths against each other.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
| attributeConfig = validAttributes[propKey]; | ||
|
|
||
| if (attributeConfig === undefined) { | ||
| if (!attributeConfig) { |
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
I personally prefer the explicitness of attributeConfig == null (which checks for both undefined and null), but this works, too.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
| } else if (typeof attributeConfig.process === 'function') { | ||
| newValue = attributeConfig.process(nextProp); | ||
| } else if (typeof attributeConfig.diff === 'function') { | ||
| newValue = nextProp; |
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Consider leaving an explanatory comment here.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
| let newValue; | ||
|
|
||
| if (typeof attributeConfig !== 'object') { | ||
| if (!updatePayload) { | ||
| updatePayload = ({}: {[string]: $FlowFixMe}); | ||
| } | ||
| updatePayload[propKey] = nextProp; | ||
| continue; | ||
| if (typeof nextProp === 'function') { | ||
| newValue = (true: any); | ||
| } else if (typeof attributeConfig !== 'object') { | ||
| newValue = nextProp; | ||
| } else if (typeof attributeConfig.process === 'function') { | ||
| newValue = attributeConfig.process(nextProp); | ||
| } else if (typeof attributeConfig.diff === 'function') { | ||
| newValue = nextProp; | ||
| } |
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Could this work?
let newValue = typeof nextProp === 'function' ? true : nextProp;
if (typeof attributeConfig === 'object' && typeof attributeConfig.process === 'function') {
newValue = attributeConfig.process(nextProp);
}
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Could do typeof attributeConfig?.process === 'function', too.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
## Summary This PR makes some fixes to the `fastAddProperties` function: - Use `if (!attributeConfig)` instead of `if (attributeConfig === undefined)` to account for `null`. - If a prop has an Object `attributeConfig` with a `diff` function defined on it, treat it as an atomic value to keep the semantics of `diffProperties`. ## How did you test this change? Build and run RNTester app. DiffTrain build for commit b37e4b4.
Completes #65845 which only updated Canary not Experimental. <details> <summary> React upstream changes</summary> - react/react#29026 - react/react#29025 - react/react#28743 - react/react#29022 - react/react#29023 - react/react#29015 - react/react#29016 - react/react#28988 - react/react#28987 - react/react#28986 - react/react#29014 - react/react#28982 - react/react#29006 - react/react#28973 - react/react#28841 - react/react#28964 - react/react#28990 - react/react#29003 - react/react#28989 - react/react#28893 - react/react#28887 - react/react#28807 - react/react#28978 - react/react#28963 - react/react#28972 - react/react#28970 - react/react#28816 - react/react#28977 - react/react#28974 - react/react#28976 - react/react#28975 - react/react#28969 - react/react#28966 - react/react#28056 </details>
## Summary This PR makes some fixes to the `fastAddProperties` function: - Use `if (!attributeConfig)` instead of `if (attributeConfig === undefined)` to account for `null`. - If a prop has an Object `attributeConfig` with a `diff` function defined on it, treat it as an atomic value to keep the semantics of `diffProperties`. ## How did you test this change? Build and run RNTester app.
There was an error while loading. Please reload this page.
Successfully merging this pull request may close these issues.
There was an error while loading. Please reload this page.