Skip to content

Commit

Permalink
Return early from enqueuePutListener for SSR (#6678)
Browse files Browse the repository at this point in the history
  • Loading branch information
aweary authored and zpao committed May 2, 2016
1 parent 468901c commit eb11648
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/renderers/dom/shared/ReactDOMComponent.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ var ReactDOMTextarea = require('ReactDOMTextarea');
var ReactInstrumentation = require('ReactInstrumentation');
var ReactMultiChild = require('ReactMultiChild');
var ReactPerf = require('ReactPerf');
var ReactServerRenderingTransaction = require('ReactServerRenderingTransaction');

var emptyFunction = require('emptyFunction');
var escapeTextContentForBrowser = require('escapeTextContentForBrowser');
Expand Down Expand Up @@ -210,6 +211,9 @@ function assertValidProps(component, props) {
}

function enqueuePutListener(inst, registrationName, listener, transaction) {
if (transaction instanceof ReactServerRenderingTransaction) {
return;
}
if (__DEV__) {
// IE8 has no API for event capturing and the `onScroll` event doesn't
// bubble.
Expand All @@ -221,10 +225,6 @@ function enqueuePutListener(inst, registrationName, listener, transaction) {
var containerInfo = inst._nativeContainerInfo;
var isDocumentFragment = containerInfo._node && containerInfo._node.nodeType === DOC_FRAGMENT_TYPE;
var doc = isDocumentFragment ? containerInfo._node : containerInfo._ownerDocument;
if (!doc) {
// Server rendering.
return;
}
listenTo(registrationName, doc);
transaction.getReactMountReady().enqueue(putListener, {
inst: inst,
Expand Down
6 changes: 6 additions & 0 deletions src/renderers/dom/shared/__tests__/ReactDOMComponent-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -1107,6 +1107,12 @@ describe('ReactDOMComponent', function() {
'Warning: This browser doesn\'t support the `onScroll` event'
);
});

it('should not warn when server-side rendering `onScroll`', function() {
spyOn(console, 'error');
ReactDOMServer.renderToString(<div onScroll={() => {}}/>);
expect(console.error).not.toHaveBeenCalled();
});
});

describe('tag sanitization', function() {
Expand Down

0 comments on commit eb11648

Please sign in to comment.