Skip to content

Commit

Permalink
When proxying statics functions, copy properties
Browse files Browse the repository at this point in the history
Port of 0760470 which went in
externally before ReactLegacyDescriptor happened, so it needed to be
ported.
  • Loading branch information
zpao committed Jul 19, 2014
1 parent 23c5332 commit de711ef
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion src/core/ReactLegacyDescriptor.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down

0 comments on commit de711ef

Please sign in to comment.