When proxying statics functions, copy properties
Port of 076047012adf8de9328e582eac35412e6bb808b2 which went in externally before ReactLegacyDescriptor happened, so it needed to be ported.
Paul O'Shannessy committed
Jul 18, 2014 at 10:03 UTC
de711efcc9c54ec416277311c682a83f60baf76e
1 file changed
+9
-1
src/core/ReactLegacyDescriptor.js
+9
-1
@@ -34,7 +34,15 @@ function proxyStaticMethods(target, source) {
34
if (source.hasOwnProperty(key)) {
35
var value = source[key];
36
if (typeof value === 'function') {
37
- target[key] = value.bind(source);
37
+ var bound = value.bind(source);
38
+ // Copy any properties defined on the function, such as `isRequired` on
39
+ // a PropTypes validator. (mergeInto refuses to work on functions.)
40
+ for (var k in value) {
41
+ if (value.hasOwnProperty(k)) {
42
+ bound[k] = value[k];
43
+ }
44
+ }
45
+ target[key] = bound;
46
} else {
47
target[key] = value;
48
}