mirror of
https://github.com/facebook/react-native.git
synced 2025-11-01 09:14:26 +00:00
f464dad5d4
Summary: Some babel plugins add additional methods to `Function.prototype` (see https://github.com/MatAtBread/fast-async): ```js Function.prototype.$asyncbind = function $asyncbind(self, catcher) { ... ``` Although undocumented, React Native allows functions to be passed to `StyleSheet.create()` for dynamic styling: ```js const styles = StyleSheet.create({ animalItem: height => ({ height }) }); ``` If there are additional custom methods on `Function.prototype`, React Native's `StyleSheetValidation.validateStyle` will loop through these properties and raise an error because those properties are not valid style keys, because it loops through _all_ properties, including inherited ones.  This PR modifies `StyleSheetValidation.validateStyle` to only loop through the style's own properties, instead of including inherited ones. ## Changelog [General] [Fixed] - Fix stylesheet validation for functions with custom prototype methods. Pull Request resolved: https://github.com/facebook/react-native/pull/27264 Test Plan: - Tested that non-function style properties are still validated Differential Revision: D18694895 Pulled By: hramos fbshipit-source-id: b36f4a62a435e7b6a689398de3bcc06d6bb14293