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 10:03:53 -07:00 committed by Paul O’Shannessy
parent 23c5332208
commit de711efcc9
1 changed files with 9 additions and 1 deletions

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;
}