diff --git a/src/browser/ReactPutListenerQueue.js b/src/browser/ReactPutListenerQueue.js deleted file mode 100644 index b897bc0abc..0000000000 --- a/src/browser/ReactPutListenerQueue.js +++ /dev/null @@ -1,54 +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 ReactPutListenerQueue - */ - -'use strict'; - -var PooledClass = require('PooledClass'); -var ReactBrowserEventEmitter = require('ReactBrowserEventEmitter'); - -var assign = require('Object.assign'); - -function ReactPutListenerQueue() { - this.listenersToPut = []; -} - -assign(ReactPutListenerQueue.prototype, { - enqueuePutListener: function(rootNodeID, propKey, propValue) { - this.listenersToPut.push({ - rootNodeID: rootNodeID, - propKey: propKey, - propValue: propValue - }); - }, - - putListeners: function() { - for (var i = 0; i < this.listenersToPut.length; i++) { - var listenerToPut = this.listenersToPut[i]; - ReactBrowserEventEmitter.putListener( - listenerToPut.rootNodeID, - listenerToPut.propKey, - listenerToPut.propValue - ); - } - }, - - reset: function() { - this.listenersToPut.length = 0; - }, - - destructor: function() { - this.reset(); - } -}); - -PooledClass.addPoolingTo(ReactPutListenerQueue); - -module.exports = ReactPutListenerQueue; diff --git a/src/browser/ReactReconcileTransaction.js b/src/browser/ReactReconcileTransaction.js index f4c69a9368..295dd9478a 100644 --- a/src/browser/ReactReconcileTransaction.js +++ b/src/browser/ReactReconcileTransaction.js @@ -16,7 +16,6 @@ var CallbackQueue = require('CallbackQueue'); var PooledClass = require('PooledClass'); var ReactBrowserEventEmitter = require('ReactBrowserEventEmitter'); var ReactInputSelection = require('ReactInputSelection'); -var ReactPutListenerQueue = require('ReactPutListenerQueue'); var Transaction = require('Transaction'); var assign = require('Object.assign'); @@ -82,23 +81,12 @@ var ON_DOM_READY_QUEUEING = { } }; -var PUT_LISTENER_QUEUEING = { - initialize: function() { - this.putListenerQueue.reset(); - }, - - close: function() { - this.putListenerQueue.putListeners(); - } -}; - /** * Executed within the scope of the `Transaction` instance. Consider these as * being member methods, but with an implied ordering while being isolated from * each other. */ var TRANSACTION_WRAPPERS = [ - PUT_LISTENER_QUEUEING, SELECTION_RESTORATION, EVENT_SUPPRESSION, ON_DOM_READY_QUEUEING @@ -127,7 +115,6 @@ function ReactReconcileTransaction() { // `ReactTextComponent` checks it in `mountComponent`.` this.renderToStaticMarkup = false; this.reactMountReady = CallbackQueue.getPooled(null); - this.putListenerQueue = ReactPutListenerQueue.getPooled(); } var Mixin = { @@ -149,10 +136,6 @@ var Mixin = { return this.reactMountReady; }, - getPutListenerQueue: function() { - return this.putListenerQueue; - }, - /** * `PooledClass` looks for this, and will invoke this before allowing this * instance to be resused. @@ -160,9 +143,6 @@ var Mixin = { destructor: function() { CallbackQueue.release(this.reactMountReady); this.reactMountReady = null; - - ReactPutListenerQueue.release(this.putListenerQueue); - this.putListenerQueue = null; } }; diff --git a/src/browser/server/ReactServerRenderingTransaction.js b/src/browser/server/ReactServerRenderingTransaction.js index 0b89ac5ad3..4379ebdfd0 100644 --- a/src/browser/server/ReactServerRenderingTransaction.js +++ b/src/browser/server/ReactServerRenderingTransaction.js @@ -14,7 +14,6 @@ var PooledClass = require('PooledClass'); var CallbackQueue = require('CallbackQueue'); -var ReactPutListenerQueue = require('ReactPutListenerQueue'); var Transaction = require('Transaction'); var assign = require('Object.assign'); @@ -35,21 +34,12 @@ var ON_DOM_READY_QUEUEING = { close: emptyFunction }; -var PUT_LISTENER_QUEUEING = { - initialize: function() { - this.putListenerQueue.reset(); - }, - - close: emptyFunction -}; - /** * Executed within the scope of the `Transaction` instance. Consider these as * being member methods, but with an implied ordering while being isolated from * each other. */ var TRANSACTION_WRAPPERS = [ - PUT_LISTENER_QUEUEING, ON_DOM_READY_QUEUEING ]; @@ -61,7 +51,6 @@ function ReactServerRenderingTransaction(renderToStaticMarkup) { this.reinitializeTransaction(); this.renderToStaticMarkup = renderToStaticMarkup; this.reactMountReady = CallbackQueue.getPooled(null); - this.putListenerQueue = ReactPutListenerQueue.getPooled(); } var Mixin = { @@ -82,10 +71,6 @@ var Mixin = { return this.reactMountReady; }, - getPutListenerQueue: function() { - return this.putListenerQueue; - }, - /** * `PooledClass` looks for this, and will invoke this before allowing this * instance to be resused. @@ -93,9 +78,6 @@ var Mixin = { destructor: function() { CallbackQueue.release(this.reactMountReady); this.reactMountReady = null; - - ReactPutListenerQueue.release(this.putListenerQueue); - this.putListenerQueue = null; } }; diff --git a/src/browser/ui/ReactDOMComponent.js b/src/browser/ui/ReactDOMComponent.js index fc3a1e447b..e1266a835b 100644 --- a/src/browser/ui/ReactDOMComponent.js +++ b/src/browser/ui/ReactDOMComponent.js @@ -100,7 +100,7 @@ function assertValidProps(component, props) { ); } -function putListener(id, registrationName, listener, transaction) { +function enqueuePutListener(id, registrationName, listener, transaction) { if (__DEV__) { // IE8 has no API for event capturing and the `onScroll` event doesn't // bubble. @@ -116,10 +116,19 @@ function putListener(id, registrationName, listener, transaction) { container; listenTo(registrationName, doc); } - transaction.getPutListenerQueue().enqueuePutListener( - id, - registrationName, - listener + transaction.getReactMountReady().enqueue(putListener, { + id: id, + registrationName: registrationName, + listener: listener + }); +} + +function putListener() { + var listenerToPut = this; + ReactBrowserEventEmitter.putListener( + listenerToPut.id, + listenerToPut.registrationName, + listenerToPut.listener ); } @@ -270,7 +279,7 @@ ReactDOMComponent.Mixin = { continue; } if (registrationNameModules.hasOwnProperty(propKey)) { - putListener(this._rootNodeID, propKey, propValue, transaction); + enqueuePutListener(this._rootNodeID, propKey, propValue, transaction); } else { if (propKey === STYLE) { if (propValue) { @@ -466,7 +475,7 @@ ReactDOMComponent.Mixin = { } } else if (registrationNameModules.hasOwnProperty(propKey)) { if (nextProp) { - putListener(this._rootNodeID, propKey, nextProp, transaction); + enqueuePutListener(this._rootNodeID, propKey, nextProp, transaction); } else if (lastProp) { deleteListener(this._rootNodeID, propKey); }