diff --git a/src/classic/class/ReactClass.js b/src/classic/class/ReactClass.js index 6eeb115203..21e0782763 100644 --- a/src/classic/class/ReactClass.js +++ b/src/classic/class/ReactClass.js @@ -485,13 +485,11 @@ function mixSpecIntoComponent(Constructor, spec) { var isReactClassMethod = ReactClassInterface.hasOwnProperty(name); var isAlreadyDefined = proto.hasOwnProperty(name); - var markedDontBind = property && property.__reactDontBind; var isFunction = typeof property === 'function'; var shouldAutoBind = isFunction && !isReactClassMethod && - !isAlreadyDefined && - !markedDontBind; + !isAlreadyDefined; if (shouldAutoBind) { if (!proto.__reactAutoBindMap) { diff --git a/src/classic/class/ReactDoNotBindDeprecated.js b/src/classic/class/ReactDoNotBindDeprecated.js deleted file mode 100644 index d43111b890..0000000000 --- a/src/classic/class/ReactDoNotBindDeprecated.js +++ /dev/null @@ -1,43 +0,0 @@ -/** - * Copyright 2013-2015, Facebook, Inc. - * All rights reserved. - * - * This source code is licensed under the BSD-style license found in the - * LICENSE file in the root directory of this source tree. An additional grant - * of patent rights can be found in the PATENTS file in the same directory. - * - * @providesModule ReactDoNotBindDeprecated - */ - -'use strict'; - -var ReactDoNotBindDeprecated = { - /** - * Marks the method for not being automatically bound on component mounting. A - * couple of reasons you might want to use this: - * - * - Automatically supporting the previous behavior in components that were - * built with previous versions of React. - * - Tuning performance, by avoiding binding on initial render for methods - * that are always invoked while being preceded by `this.`. Such binds are - * unnecessary. - * - * React.createClass({ - * handleClick: ReactDoNotBindDeprecated.doNotBind(function() { - * alert(this.setState); // undefined! - * }), - * render: function() { - * return Jump; - * } - * }); - * - * @param {function} method Method to avoid automatically binding. - * @public - */ - doNotBind: function(method) { - method.__reactDontBind = true; // Mutating - return method; - } -}; - -module.exports = ReactDoNotBindDeprecated; diff --git a/src/classic/class/__tests__/ReactBind-test.js b/src/classic/class/__tests__/ReactBind-test.js index 856131a978..78caa70c64 100644 --- a/src/classic/class/__tests__/ReactBind-test.js +++ b/src/classic/class/__tests__/ReactBind-test.js @@ -13,7 +13,6 @@ var mocks = require('mocks'); var React = require('React'); -var ReactDoNotBindDeprecated = require('ReactDoNotBindDeprecated'); var ReactTestUtils = require('ReactTestUtils'); var reactComponentExpect = require('reactComponentExpect'); @@ -30,8 +29,8 @@ describe('autobinding', function() { getInitialState: function() { return {something: 'hi'}; }, - onMouseEnter: ReactDoNotBindDeprecated.doNotBind(mouseDidEnter), - onMouseLeave: ReactDoNotBindDeprecated.doNotBind(mouseDidLeave), + onMouseEnter: mouseDidEnter, + onMouseLeave: mouseDidLeave, onClick: mouseDidClick, // auto binding only occurs on top level functions in class defs. @@ -44,7 +43,7 @@ describe('autobinding', function() { render: function() { return (
@@ -69,8 +68,6 @@ describe('autobinding', function() { badIdea(); }).toThrow(); - expect(mountedInstance1.onMouseEnter).toBe(mountedInstance2.onMouseEnter); - expect(mountedInstance1.onMouseLeave).toBe(mountedInstance2.onMouseLeave); expect(mountedInstance1.onClick).not.toBe(mountedInstance2.onClick); ReactTestUtils.Simulate.click(rendered1); @@ -91,11 +88,11 @@ describe('autobinding', function() { ReactTestUtils.Simulate.mouseOut(rendered1); expect(mouseDidLeave.mock.instances.length).toBe(1); - expect(mouseDidLeave.mock.instances[0]).toBe(global); + expect(mouseDidLeave.mock.instances[0]).toBe(mountedInstance1); ReactTestUtils.Simulate.mouseOut(rendered2); expect(mouseDidLeave.mock.instances.length).toBe(2); - expect(mouseDidLeave.mock.instances[1]).toBe(global); + expect(mouseDidLeave.mock.instances[1]).toBe(mountedInstance2); }); it('works with mixins', function() { diff --git a/src/core/__tests__/ReactCompositeComponent-test.js b/src/core/__tests__/ReactCompositeComponent-test.js index 669f2c6c2c..09bae039cc 100644 --- a/src/core/__tests__/ReactCompositeComponent-test.js +++ b/src/core/__tests__/ReactCompositeComponent-test.js @@ -15,7 +15,6 @@ var ChildUpdates; var MorphingComponent; var React; var ReactCurrentOwner; -var ReactDoNotBindDeprecated; var ReactMount; var ReactPropTypes; var ReactServerRendering; @@ -33,7 +32,6 @@ describe('ReactCompositeComponent', function() { reactComponentExpect = require('reactComponentExpect'); React = require('React'); ReactCurrentOwner = require('ReactCurrentOwner'); - ReactDoNotBindDeprecated = require('ReactDoNotBindDeprecated'); ReactPropTypes = require('ReactPropTypes'); ReactTestUtils = require('ReactTestUtils'); ReactMount = require('ReactMount'); @@ -170,9 +168,6 @@ describe('ReactCompositeComponent', function() { methodAutoBound: function() { return this; }, - methodExplicitlyNotBound: ReactDoNotBindDeprecated.doNotBind(function() { - return this; - }), render: function() { return ; } @@ -189,9 +184,6 @@ describe('ReactCompositeComponent', function() { expect(function() { mountedInstance.methodAutoBound(); }).not.toThrow(); - expect(function() { - mountedInstance.methodExplicitlyNotBound(); - }).not.toThrow(); expect(console.error.argsForCall.length).toBe(1); var explicitlyBound = mountedInstance.methodToBeExplicitlyBound.bind( @@ -199,17 +191,13 @@ describe('ReactCompositeComponent', function() { ); expect(console.error.argsForCall.length).toBe(2); var autoBound = mountedInstance.methodAutoBound; - var explicitlyNotBound = mountedInstance.methodExplicitlyNotBound; var context = {}; expect(explicitlyBound.call(context)).toBe(mountedInstance); expect(autoBound.call(context)).toBe(mountedInstance); - expect(explicitlyNotBound.call(context)).toBe(context); expect(explicitlyBound.call(mountedInstance)).toBe(mountedInstance); expect(autoBound.call(mountedInstance)).toBe(mountedInstance); - // This one is the weird one - expect(explicitlyNotBound.call(mountedInstance)).toBe(mountedInstance); });