Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 11 additions & 5 deletions src/core/ReactMount.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,9 @@ var SEPARATOR = ReactInstanceHandles.SEPARATOR;
var ATTR_NAME = 'data-reactid';
var nodeCache = {};

var ELEMENT_NODE_TYPE = 1;
var DOC_NODE_TYPE = 9;

var $ = require('$');

/** Mapping from reactRootID to React component instance. */
Expand Down Expand Up @@ -235,13 +238,16 @@ var ReactMount = {
*/
prepareEnvironmentForDOM: function(container) {
invariant(
container && container.nodeType === 1,
container && (
container.nodeType === ELEMENT_NODE_TYPE ||
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I didn't think of this earlier (and I'm not going to block this diff), but we should probably consider using Node.ELEMENT_NODE and Node.DOCUMENT_NODE).

container.nodeType === DOC_NODE_TYPE
),
'prepareEnvironmentForDOM(...): Target container is not a DOM element.'
);
ReactEventEmitter.ensureListening(
ReactMount.useTouchEvents,
container.ownerDocument
);
var doc = container.nodeType === ELEMENT_NODE_TYPE ?
container.ownerDocument :
container;
ReactEventEmitter.ensureListening(ReactMount.useTouchEvents, doc);
},

/**
Expand Down