Kill ReactPutListenerQueue
As far as I can tell, this is almost equivalent and is simpler. When a component's componentDidMount is called, all the listeners for that subtree will have been attached which I think is all that matters.
Ben Alpert committed
Apr 4, 2015 at 17:31 UTC
7529e6de47e68d2fd4484529bd1c99e36752db7d
4 files changed
+16
-99
src/browser/ReactPutListenerQueue.js
deleted
-54
@@ -1,54 +0,0 @@
1
-/**
2
- * Copyright 2013-2015, Facebook, Inc.
3
- * All rights reserved.
4
- *
5
- * This source code is licensed under the BSD-style license found in the
6
- * LICENSE file in the root directory of this source tree. An additional grant
7
- * of patent rights can be found in the PATENTS file in the same directory.
8
- *
9
- * @providesModule ReactPutListenerQueue
10
- */
11
-
12
-'use strict';
13
-
14
-var PooledClass = require('PooledClass');
15
-var ReactBrowserEventEmitter = require('ReactBrowserEventEmitter');
16
-
17
-var assign = require('Object.assign');
18
-
19
-function ReactPutListenerQueue() {
20
- this.listenersToPut = [];
21
-}
22
-
23
-assign(ReactPutListenerQueue.prototype, {
24
- enqueuePutListener: function(rootNodeID, propKey, propValue) {
25
- this.listenersToPut.push({
26
- rootNodeID: rootNodeID,
27
- propKey: propKey,
28
- propValue: propValue
29
- });
30
- },
31
-
32
- putListeners: function() {
33
- for (var i = 0; i < this.listenersToPut.length; i++) {
34
- var listenerToPut = this.listenersToPut[i];
35
- ReactBrowserEventEmitter.putListener(
36
- listenerToPut.rootNodeID,
37
- listenerToPut.propKey,
38
- listenerToPut.propValue
39
- );
40
- }
41
- },
42
-
43
- reset: function() {
44
- this.listenersToPut.length = 0;
45
- },
46
-
47
- destructor: function() {
48
- this.reset();
49
- }
50
-});
51
-
52
-PooledClass.addPoolingTo(ReactPutListenerQueue);
53
-
54
-module.exports = ReactPutListenerQueue;
src/browser/ReactReconcileTransaction.js
-20
@@ -16,7 +16,6 @@ var CallbackQueue = require('CallbackQueue');
16
var PooledClass = require('PooledClass');
17
var ReactBrowserEventEmitter = require('ReactBrowserEventEmitter');
18
var ReactInputSelection = require('ReactInputSelection');
19
-var ReactPutListenerQueue = require('ReactPutListenerQueue');
19
var Transaction = require('Transaction');
20
21
var assign = require('Object.assign');
@@ -82,23 +81,12 @@ var ON_DOM_READY_QUEUEING = {
81
}
82
};
83
85
-var PUT_LISTENER_QUEUEING = {
86
- initialize: function() {
87
- this.putListenerQueue.reset();
88
- },
89
-
90
- close: function() {
91
- this.putListenerQueue.putListeners();
92
- }
93
-};
94
-
84
/**
85
* Executed within the scope of the `Transaction` instance. Consider these as
86
* being member methods, but with an implied ordering while being isolated from
87
* each other.
88
*/
89
var TRANSACTION_WRAPPERS = [
101
- PUT_LISTENER_QUEUEING,
90
SELECTION_RESTORATION,
91
EVENT_SUPPRESSION,
92
ON_DOM_READY_QUEUEING
@@ -127,7 +115,6 @@ function ReactReconcileTransaction() {
115
// `ReactTextComponent` checks it in `mountComponent`.`
116
this.renderToStaticMarkup = false;
117
this.reactMountReady = CallbackQueue.getPooled(null);
130
- this.putListenerQueue = ReactPutListenerQueue.getPooled();
118
}
119
120
var Mixin = {
@@ -149,10 +136,6 @@ var Mixin = {
136
return this.reactMountReady;
137
},
138
152
- getPutListenerQueue: function() {
153
- return this.putListenerQueue;
154
- },
155
-
139
/**
140
* `PooledClass` looks for this, and will invoke this before allowing this
141
* instance to be resused.
@@ -160,9 +143,6 @@ var Mixin = {
143
destructor: function() {
144
CallbackQueue.release(this.reactMountReady);
145
this.reactMountReady = null;
163
-
164
- ReactPutListenerQueue.release(this.putListenerQueue);
165
- this.putListenerQueue = null;
146
}
147
};
148
src/browser/server/ReactServerRenderingTransaction.js
-18
@@ -14,7 +14,6 @@
14
15
var PooledClass = require('PooledClass');
16
var CallbackQueue = require('CallbackQueue');
17
-var ReactPutListenerQueue = require('ReactPutListenerQueue');
17
var Transaction = require('Transaction');
18
19
var assign = require('Object.assign');
@@ -35,21 +34,12 @@ var ON_DOM_READY_QUEUEING = {
34
close: emptyFunction
35
};
36
38
-var PUT_LISTENER_QUEUEING = {
39
- initialize: function() {
40
- this.putListenerQueue.reset();
41
- },
42
-
43
- close: emptyFunction
44
-};
45
-
37
/**
38
* Executed within the scope of the `Transaction` instance. Consider these as
39
* being member methods, but with an implied ordering while being isolated from
40
* each other.
41
*/
42
var TRANSACTION_WRAPPERS = [
52
- PUT_LISTENER_QUEUEING,
43
ON_DOM_READY_QUEUEING
44
];
45
@@ -61,7 +51,6 @@ function ReactServerRenderingTransaction(renderToStaticMarkup) {
51
this.reinitializeTransaction();
52
this.renderToStaticMarkup = renderToStaticMarkup;
53
this.reactMountReady = CallbackQueue.getPooled(null);
64
- this.putListenerQueue = ReactPutListenerQueue.getPooled();
54
}
55
56
var Mixin = {
@@ -82,10 +71,6 @@ var Mixin = {
71
return this.reactMountReady;
72
},
73
85
- getPutListenerQueue: function() {
86
- return this.putListenerQueue;
87
- },
88
-
74
/**
75
* `PooledClass` looks for this, and will invoke this before allowing this
76
* instance to be resused.
@@ -93,9 +78,6 @@ var Mixin = {
78
destructor: function() {
79
CallbackQueue.release(this.reactMountReady);
80
this.reactMountReady = null;
96
-
97
- ReactPutListenerQueue.release(this.putListenerQueue);
98
- this.putListenerQueue = null;
81
}
82
};
83
src/browser/ui/ReactDOMComponent.js
+16
-7
@@ -100,7 +100,7 @@ function assertValidProps(component, props) {
100
);
101
}
102
103
-function putListener(id, registrationName, listener, transaction) {
103
+function enqueuePutListener(id, registrationName, listener, transaction) {
104
if (__DEV__) {
105
// IE8 has no API for event capturing and the `onScroll` event doesn't
106
// bubble.
@@ -116,10 +116,19 @@ function putListener(id, registrationName, listener, transaction) {
116
container;
117
listenTo(registrationName, doc);
118
}
119
- transaction.getPutListenerQueue().enqueuePutListener(
120
- id,
121
- registrationName,
122
- listener
119
+ transaction.getReactMountReady().enqueue(putListener, {
120
+ id: id,
121
+ registrationName: registrationName,
122
+ listener: listener
123
+ });
124
+}
125
+
126
+function putListener() {
127
+ var listenerToPut = this;
128
+ ReactBrowserEventEmitter.putListener(
129
+ listenerToPut.id,
130
+ listenerToPut.registrationName,
131
+ listenerToPut.listener
132
);
133
}
134
@@ -270,7 +279,7 @@ ReactDOMComponent.Mixin = {
279
continue;
280
}
281
if (registrationNameModules.hasOwnProperty(propKey)) {
273
- putListener(this._rootNodeID, propKey, propValue, transaction);
282
+ enqueuePutListener(this._rootNodeID, propKey, propValue, transaction);
283
} else {
284
if (propKey === STYLE) {
285
if (propValue) {
@@ -466,7 +475,7 @@ ReactDOMComponent.Mixin = {
475
}
476
} else if (registrationNameModules.hasOwnProperty(propKey)) {
477
if (nextProp) {
469
- putListener(this._rootNodeID, propKey, nextProp, transaction);
478
+ enqueuePutListener(this._rootNodeID, propKey, nextProp, transaction);
479
} else if (lastProp) {
480
deleteListener(this._rootNodeID, propKey);
481
}