@samitouri / QOS-React-2 / commits / ed9c0ca87c

Expose bound function, context and arguments

Exposes the bound context, original method and bound arguments for any auto-bound methods, for debugging purposes.

Sebastian Markbage committed Oct 7, 2013 at 14:53 UTC ed9c0ca87c2a7ceb8803ee26cf0beacba9a23176
1 file changed +9 -1
src/core/ReactCompositeComponent.js
+9 -1
@@ -891,6 +891,9 @@ var ReactCompositeComponentMixin = {
891 return method.apply(component, arguments);
892 };
893 if (__DEV__) {
894 + boundMethod.__reactBoundContext = component;
895 + boundMethod.__reactBoundMethod = method;
896 + boundMethod.__reactBoundArguments = null;
897 var componentName = component.constructor.displayName;
898 var _bind = boundMethod.bind;
899 boundMethod.bind = function(newThis) {
@@ -910,7 +913,12 @@ var ReactCompositeComponentMixin = {
913 );
914 return boundMethod;
915 }
913 - return _bind.apply(boundMethod, arguments);
916 + var reboundMethod = _bind.apply(boundMethod, arguments);
917 + reboundMethod.__reactBoundContext = component;
918 + reboundMethod.__reactBoundMethod = method;
919 + reboundMethod.__reactBoundArguments =
920 + Array.prototype.slice.call(arguments, 1);
921 + return reboundMethod;
922 };
923 }
924 return boundMethod;