Use .bind when autobinding

This eliminates all of the `boundMethod` frames from call stacks when debugging and as far as I know should behave the same otherwise.

Test Plan: jest
This commit is contained in:
Ben Alpert 2014-07-24 12:11:19 -07:00
parent efdc5da097
commit f1508c4937
2 changed files with 2 additions and 4 deletions

View File

@ -1265,9 +1265,7 @@ var ReactCompositeComponentMixin = {
*/
_bindAutoBindMethod: function(method) {
var component = this;
var boundMethod = function() {
return method.apply(component, arguments);
};
var boundMethod = method.bind(component);
if (__DEV__) {
boundMethod.__reactBoundContext = component;
boundMethod.__reactBoundMethod = method;

View File

@ -26,7 +26,7 @@ var ReactErrorUtils = require('ReactErrorUtils');
describe('ReactCompositeComponent-error', function() {
it('should be passed the component and method name', function() {
spyOn(ReactErrorUtils, 'guard');
spyOn(ReactErrorUtils, 'guard').andCallThrough();
var Component = React.createClass({
someHandler: function() {},
render: function() {