Skip to content

Commit 8866c6a

Browse files
Brandon DailBrandon Dail
Brandon Dail
authored and
Brandon Dail
committed
Return early from enqueuePutListener for SSR
1 parent 261bf28 commit 8866c6a

File tree

2 files changed

+10
-4
lines changed

2 files changed

+10
-4
lines changed

src/renderers/dom/shared/ReactDOMComponent.js

+4-4
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ var ReactDOMTextarea = require('ReactDOMTextarea');
3535
var ReactInstrumentation = require('ReactInstrumentation');
3636
var ReactMultiChild = require('ReactMultiChild');
3737
var ReactPerf = require('ReactPerf');
38+
var ReactServerRenderingTransaction = require('ReactServerRenderingTransaction');
3839

3940
var emptyFunction = require('emptyFunction');
4041
var escapeTextContentForBrowser = require('escapeTextContentForBrowser');
@@ -210,6 +211,9 @@ function assertValidProps(component, props) {
210211
}
211212

212213
function enqueuePutListener(inst, registrationName, listener, transaction) {
214+
if (transaction instanceof ReactServerRenderingTransaction) {
215+
return;
216+
}
213217
if (__DEV__) {
214218
// IE8 has no API for event capturing and the `onScroll` event doesn't
215219
// bubble.
@@ -221,10 +225,6 @@ function enqueuePutListener(inst, registrationName, listener, transaction) {
221225
var containerInfo = inst._nativeContainerInfo;
222226
var isDocumentFragment = containerInfo._node && containerInfo._node.nodeType === DOC_FRAGMENT_TYPE;
223227
var doc = isDocumentFragment ? containerInfo._node : containerInfo._ownerDocument;
224-
if (!doc) {
225-
// Server rendering.
226-
return;
227-
}
228228
listenTo(registrationName, doc);
229229
transaction.getReactMountReady().enqueue(putListener, {
230230
inst: inst,

src/renderers/dom/shared/__tests__/ReactDOMComponent-test.js

+6
Original file line numberDiff line numberDiff line change
@@ -1107,6 +1107,12 @@ describe('ReactDOMComponent', function() {
11071107
'Warning: This browser doesn\'t support the `onScroll` event'
11081108
);
11091109
});
1110+
1111+
it('should not warn when server-side rendering `onScroll`', function() {
1112+
spyOn(console, 'error');
1113+
ReactDOMServer.renderToString(<div onScroll={() => {}}/>);
1114+
expect(console.error).not.toHaveBeenCalled();
1115+
});
11101116
});
11111117

11121118
describe('tag sanitization', function() {

0 commit comments

Comments
 (0)