Skip to content

Commit

Permalink
Listen DOM events in each React container
Browse files Browse the repository at this point in the history
Current React implementation is attaching events to `document` level.
This is breaking bubbling DOM behaviour not letting users to play
properly with methods like `stopPropagation`.

Also attaching events to containers instead of `document` integrates
better with other Javascript frameworks.

With this change we start attaching events at container level.

Fixes:
facebook#2043
facebook#4335
  • Loading branch information
fcsonline committed Jun 20, 2016
1 parent 489caeb commit cdd87b7
Showing 1 changed file with 1 addition and 7 deletions.
8 changes: 1 addition & 7 deletions src/renderers/dom/shared/ReactDOMComponent.js
Original file line number Diff line number Diff line change
Expand Up @@ -63,10 +63,6 @@ var RESERVED_PROPS = {
suppressContentEditableWarning: null,
};

// Node type for document fragments (Node.DOCUMENT_FRAGMENT_NODE).
var DOC_FRAGMENT_TYPE = 11;


function getDeclarationErrorAddendum(internalInstance) {
if (internalInstance) {
var owner = internalInstance._currentElement._owner || null;
Expand Down Expand Up @@ -222,9 +218,7 @@ function enqueuePutListener(inst, registrationName, listener, transaction) {
);
}
var containerInfo = inst._hostContainerInfo;
var isDocumentFragment = containerInfo._node && containerInfo._node.nodeType === DOC_FRAGMENT_TYPE;
var doc = isDocumentFragment ? containerInfo._node : containerInfo._ownerDocument;
listenTo(registrationName, doc);
listenTo(registrationName, containerInfo._node);
transaction.getReactMountReady().enqueue(putListener, {
inst: inst,
registrationName: registrationName,
Expand Down

0 comments on commit cdd87b7

Please sign in to comment.