Short-circuit the check just for getters
This way in other cases both DEV and PROD falls through to the check for undefined. This fixes #6879 and a similar bug introduced for cloneElement() in 94d0dc68c89c0292cd430976a7dafb95f8d13cf4.
Dan Abramov committed
May 26, 2016 at 00:21 UTC
c77411b1af3abe62d35c981089dca6e4624cf44c
1 file changed
+8
-4
src/isomorphic/classic/element/ReactElement.js
+8
-4
@@ -34,16 +34,20 @@ var specialPropKeyWarningShown, specialPropRefWarningShown;
34
35
function hasValidRef(config) {
36
if (__DEV__) {
37
- return hasOwnProperty.call(config, 'ref') &&
38
- !Object.getOwnPropertyDescriptor(config, 'ref').get;
37
+ if (hasOwnProperty.call(config, 'ref') &&
38
+ Object.getOwnPropertyDescriptor(config, 'ref').get) {
39
+ return false;
40
+ }
41
}
42
return config.ref !== undefined;
43
}
44
45
function hasValidKey(config) {
46
if (__DEV__) {
45
- return hasOwnProperty.call(config, 'key') &&
46
- !Object.getOwnPropertyDescriptor(config, 'key').get;
47
+ if (hasOwnProperty.call(config, 'key') &&
48
+ Object.getOwnPropertyDescriptor(config, 'key').get) {
49
+ return false;
50
+ }
51
}
52
return config.key !== undefined;
53
}