Skip to content
Closed
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
18 changes: 15 additions & 3 deletions src/browser/ui/ReactDOMComponent.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@ var CONTENT_TYPES = {'string': true, 'number': true};
var STYLE = keyOf({style: null});

var ELEMENT_NODE_TYPE = 1;
var DOC_NODE_TYPE = 9;
var DOCUMENT_FRAGMENT_NODE_TYPE = 11;

/**
* Optionally injectable operations for mutating the DOM
Expand Down Expand Up @@ -100,9 +102,19 @@ function putListener(id, registrationName, listener, transaction) {
}
var container = ReactMount.findReactContainerForID(id);
if (container) {
var doc = container.nodeType === ELEMENT_NODE_TYPE ?
container.ownerDocument :
container;

var doc = container; // Walk up from container to find best document
while (doc !== null &&
doc.nodeType !== DOC_NODE_TYPE &&
doc.nodeType !== DOCUMENT_FRAGMENT_NODE_TYPE) {
doc = doc.parentNode;
}

// If the container isn't mounted in a document, register with the default document
if (doc === null && container.nodeType === ELEMENT_NODE_TYPE) {
doc = container.ownerDocument;
}

listenTo(registrationName, doc);
}
transaction.getPutListenerQueue().enqueuePutListener(
Expand Down