When proxying statics functions, copy properties

Port of 076047012a which went in
externally before ReactLegacyDescriptor happened, so it needed to be
ported.
This commit is contained in:
Paul O'Shannessy
2014-07-18 22:01:36 -07:00
committed by Paul O’Shannessy
parent 23c5332208
commit de711efcc9
+9 -1
View File
@@ -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;
}