From de711efcc9c54ec416277311c682a83f60baf76e Mon Sep 17 00:00:00 2001 From: Paul O'Shannessy Date: Fri, 18 Jul 2014 10:03:53 -0700 Subject: [PATCH] When proxying statics functions, copy properties Port of 076047012adf8de9328e582eac35412e6bb808b2 which went in externally before ReactLegacyDescriptor happened, so it needed to be ported. --- src/core/ReactLegacyDescriptor.js | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/core/ReactLegacyDescriptor.js b/src/core/ReactLegacyDescriptor.js index 712ac2461d..e6ba9efa77 100644 --- a/src/core/ReactLegacyDescriptor.js +++ b/src/core/ReactLegacyDescriptor.js @@ -34,7 +34,15 @@ function proxyStaticMethods(target, source) { if (source.hasOwnProperty(key)) { var value = source[key]; if (typeof value === 'function') { - target[key] = value.bind(source); + var bound = value.bind(source); + // Copy any properties defined on the function, such as `isRequired` on + // a PropTypes validator. (mergeInto refuses to work on functions.) + for (var k in value) { + if (value.hasOwnProperty(k)) { + bound[k] = value[k]; + } + } + target[key] = bound; } else { target[key] = value; }