put/deleteListener take an instance, not an ID

This removes SimpleEventPlugin's dependency on ReactMount.getID.
This commit is contained in:
Ben Alpert committed 2015-11-04 11:39:43 -08:00
1 parent d11ccd6956
commit 796f8c353c
9 files changed
+128 -126

No files matched your search

@@ -46,14 +46,14 @@ var PARENT;
var CHILD;
function registerSimpleTestHandler() {
EventPluginHub.putListener(getID(CHILD), ON_CLICK_KEY, LISTENER);
var listener = EventPluginHub.getListener(getID(CHILD), ON_CLICK_KEY);
EventPluginHub.putListener(getInternal(CHILD), ON_CLICK_KEY, LISTENER);
var listener = EventPluginHub.getListener(getInternal(CHILD), ON_CLICK_KEY);
expect(listener).toEqual(LISTENER);
return EventPluginHub.getListener(getID(CHILD), ON_CLICK_KEY);
return EventPluginHub.getListener(getInternal(CHILD), ON_CLICK_KEY);
}
function getID(node) {
return ReactDOMComponentTree.getInstanceFromNode(node)._rootNodeID;
function getInternal(node) {
return ReactDOMComponentTree.getInstanceFromNode(node);
}
@@ -87,20 +87,20 @@ describe('ReactBrowserEventEmitter', function() {
it('should store a listener correctly', function() {
registerSimpleTestHandler();
var listener = EventPluginHub.getListener(getID(CHILD), ON_CLICK_KEY);
var listener = EventPluginHub.getListener(getInternal(CHILD), ON_CLICK_KEY);
expect(listener).toBe(LISTENER);
});
it('should retrieve a listener correctly', function() {
registerSimpleTestHandler();
var listener = EventPluginHub.getListener(getID(CHILD), ON_CLICK_KEY);
var listener = EventPluginHub.getListener(getInternal(CHILD), ON_CLICK_KEY);
expect(listener).toEqual(LISTENER);
});
it('should clear all handlers when asked to', function() {
registerSimpleTestHandler();
EventPluginHub.deleteAllListeners(getID(CHILD));
var listener = EventPluginHub.getListener(getID(CHILD), ON_CLICK_KEY);
EventPluginHub.deleteAllListeners(getInternal(CHILD));
var listener = EventPluginHub.getListener(getInternal(CHILD), ON_CLICK_KEY);
expect(listener).toBe(undefined);
});
@@ -125,152 +125,152 @@ describe('ReactBrowserEventEmitter', function() {
it('should bubble simply', function() {
EventPluginHub.putListener(
getID(CHILD),
getInternal(CHILD),
ON_CLICK_KEY,
recordID.bind(null, getID(CHILD))
recordID.bind(null, getInternal(CHILD))
);
EventPluginHub.putListener(
getID(PARENT),
getInternal(PARENT),
ON_CLICK_KEY,
recordID.bind(null, getID(PARENT))
recordID.bind(null, getInternal(PARENT))
);
EventPluginHub.putListener(
getID(GRANDPARENT),
getInternal(GRANDPARENT),
ON_CLICK_KEY,
recordID.bind(null, getID(GRANDPARENT))
recordID.bind(null, getInternal(GRANDPARENT))
);
ReactTestUtils.Simulate.click(CHILD);
expect(idCallOrder.length).toBe(3);
expect(idCallOrder[0]).toBe(getID(CHILD));
expect(idCallOrder[1]).toBe(getID(PARENT));
expect(idCallOrder[2]).toBe(getID(GRANDPARENT));
expect(idCallOrder[0]).toBe(getInternal(CHILD));
expect(idCallOrder[1]).toBe(getInternal(PARENT));
expect(idCallOrder[2]).toBe(getInternal(GRANDPARENT));
});
it('should continue bubbling if an error is thrown', function() {
EventPluginHub.putListener(
getID(CHILD),
getInternal(CHILD),
ON_CLICK_KEY,
recordID.bind(null, getID(CHILD))
recordID.bind(null, getInternal(CHILD))
);
EventPluginHub.putListener(
getID(PARENT),
getInternal(PARENT),
ON_CLICK_KEY,
function() {
recordID(getID(PARENT));
recordID(getInternal(PARENT));
throw new Error('Handler interrupted');
}
);
EventPluginHub.putListener(
getID(GRANDPARENT),
getInternal(GRANDPARENT),
ON_CLICK_KEY,
recordID.bind(null, getID(GRANDPARENT))
recordID.bind(null, getInternal(GRANDPARENT))
);
expect(function() {
ReactTestUtils.Simulate.click(CHILD);
}).toThrow();
expect(idCallOrder.length).toBe(3);
expect(idCallOrder[0]).toBe(getID(CHILD));
expect(idCallOrder[1]).toBe(getID(PARENT));
expect(idCallOrder[2]).toBe(getID(GRANDPARENT));
expect(idCallOrder[0]).toBe(getInternal(CHILD));
expect(idCallOrder[1]).toBe(getInternal(PARENT));
expect(idCallOrder[2]).toBe(getInternal(GRANDPARENT));
});
it('should set currentTarget', function() {
EventPluginHub.putListener(
getID(CHILD),
getInternal(CHILD),
ON_CLICK_KEY,
function(event) {
recordID(getID(CHILD));
recordID(getInternal(CHILD));
expect(event.currentTarget).toBe(CHILD);
}
);
EventPluginHub.putListener(
getID(PARENT),
getInternal(PARENT),
ON_CLICK_KEY,
function(event) {
recordID(getID(PARENT));
recordID(getInternal(PARENT));
expect(event.currentTarget).toBe(PARENT);
}
);
EventPluginHub.putListener(
getID(GRANDPARENT),
getInternal(GRANDPARENT),
ON_CLICK_KEY,
function(event) {
recordID(getID(GRANDPARENT));
recordID(getInternal(GRANDPARENT));
expect(event.currentTarget).toBe(GRANDPARENT);
}
);
ReactTestUtils.Simulate.click(CHILD);
expect(idCallOrder.length).toBe(3);
expect(idCallOrder[0]).toBe(getID(CHILD));
expect(idCallOrder[1]).toBe(getID(PARENT));
expect(idCallOrder[2]).toBe(getID(GRANDPARENT));
expect(idCallOrder[0]).toBe(getInternal(CHILD));
expect(idCallOrder[1]).toBe(getInternal(PARENT));
expect(idCallOrder[2]).toBe(getInternal(GRANDPARENT));
});
it('should support stopPropagation()', function() {
EventPluginHub.putListener(
getID(CHILD),
getInternal(CHILD),
ON_CLICK_KEY,
recordID.bind(null, getID(CHILD))
recordID.bind(null, getInternal(CHILD))
);
EventPluginHub.putListener(
getID(PARENT),
getInternal(PARENT),
ON_CLICK_KEY,
recordIDAndStopPropagation.bind(null, getID(PARENT))
recordIDAndStopPropagation.bind(null, getInternal(PARENT))
);
EventPluginHub.putListener(
getID(GRANDPARENT),
getInternal(GRANDPARENT),
ON_CLICK_KEY,
recordID.bind(null, getID(GRANDPARENT))
recordID.bind(null, getInternal(GRANDPARENT))
);
ReactTestUtils.Simulate.click(CHILD);
expect(idCallOrder.length).toBe(2);
expect(idCallOrder[0]).toBe(getID(CHILD));
expect(idCallOrder[1]).toBe(getID(PARENT));
expect(idCallOrder[0]).toBe(getInternal(CHILD));
expect(idCallOrder[1]).toBe(getInternal(PARENT));
});
it('should stop after first dispatch if stopPropagation', function() {
EventPluginHub.putListener(
getID(CHILD),
getInternal(CHILD),
ON_CLICK_KEY,
recordIDAndStopPropagation.bind(null, getID(CHILD))
recordIDAndStopPropagation.bind(null, getInternal(CHILD))
);
EventPluginHub.putListener(
getID(PARENT),
getInternal(PARENT),
ON_CLICK_KEY,
recordID.bind(null, getID(PARENT))
recordID.bind(null, getInternal(PARENT))
);
EventPluginHub.putListener(
getID(GRANDPARENT),
getInternal(GRANDPARENT),
ON_CLICK_KEY,
recordID.bind(null, getID(GRANDPARENT))
recordID.bind(null, getInternal(GRANDPARENT))
);
ReactTestUtils.Simulate.click(CHILD);
expect(idCallOrder.length).toBe(1);
expect(idCallOrder[0]).toBe(getID(CHILD));
expect(idCallOrder[0]).toBe(getInternal(CHILD));
});
it('should not stopPropagation if false is returned', function() {
EventPluginHub.putListener(
getID(CHILD),
getInternal(CHILD),
ON_CLICK_KEY,
recordIDAndReturnFalse.bind(null, getID(CHILD))
recordIDAndReturnFalse.bind(null, getInternal(CHILD))
);
EventPluginHub.putListener(
getID(PARENT),
getInternal(PARENT),
ON_CLICK_KEY,
recordID.bind(null, getID(PARENT))
recordID.bind(null, getInternal(PARENT))
);
EventPluginHub.putListener(
getID(GRANDPARENT),
getInternal(GRANDPARENT),
ON_CLICK_KEY,
recordID.bind(null, getID(GRANDPARENT))
recordID.bind(null, getInternal(GRANDPARENT))
);
spyOn(console, 'error');
ReactTestUtils.Simulate.click(CHILD);
expect(idCallOrder.length).toBe(3);
expect(idCallOrder[0]).toBe(getID(CHILD));
expect(idCallOrder[1]).toBe(getID(PARENT));
expect(idCallOrder[2]).toBe(getID(GRANDPARENT));
expect(idCallOrder[0]).toBe(getInternal(CHILD));
expect(idCallOrder[1]).toBe(getInternal(PARENT));
expect(idCallOrder[2]).toBe(getInternal(GRANDPARENT));
expect(console.error.calls.length).toEqual(0);
});
@@ -286,15 +286,15 @@ describe('ReactBrowserEventEmitter', function() {
it('should invoke handlers that were removed while bubbling', function() {
var handleParentClick = jest.genMockFn();
var handleChildClick = function(event) {
EventPluginHub.deleteAllListeners(getID(PARENT));
EventPluginHub.deleteAllListeners(getInternal(PARENT));
};
EventPluginHub.putListener(
getID(CHILD),
getInternal(CHILD),
ON_CLICK_KEY,
handleChildClick
);
EventPluginHub.putListener(
getID(PARENT),
getInternal(PARENT),
ON_CLICK_KEY,
handleParentClick
);
@@ -306,13 +306,13 @@ describe('ReactBrowserEventEmitter', function() {
var handleParentClick = jest.genMockFn();
var handleChildClick = function(event) {
EventPluginHub.putListener(
getID(PARENT),
getInternal(PARENT),
ON_CLICK_KEY,
handleParentClick
);
};
EventPluginHub.putListener(
getID(CHILD),
getInternal(CHILD),
ON_CLICK_KEY,
handleChildClick
);
@@ -322,20 +322,20 @@ describe('ReactBrowserEventEmitter', function() {
it('should have mouse enter simulated by test utils', function() {
EventPluginHub.putListener(
getID(CHILD),
getInternal(CHILD),
ON_MOUSE_ENTER_KEY,
recordID.bind(null, getID(CHILD))
recordID.bind(null, getInternal(CHILD))
);
ReactTestUtils.Simulate.mouseEnter(CHILD);
expect(idCallOrder.length).toBe(1);
expect(idCallOrder[0]).toBe(getID(CHILD));
expect(idCallOrder[0]).toBe(getInternal(CHILD));
});
it('should infer onTouchTap from a touchStart/End', function() {
EventPluginHub.putListener(
getID(CHILD),
getInternal(CHILD),
ON_TOUCH_TAP_KEY,
recordID.bind(null, getID(CHILD))
recordID.bind(null, getInternal(CHILD))
);
ReactTestUtils.SimulateNative.touchStart(
CHILD,
@@ -346,14 +346,14 @@ describe('ReactBrowserEventEmitter', function() {
ReactTestUtils.nativeTouchData(0, 0)
);
expect(idCallOrder.length).toBe(1);
expect(idCallOrder[0]).toBe(getID(CHILD));
expect(idCallOrder[0]).toBe(getInternal(CHILD));
});
it('should infer onTouchTap from when dragging below threshold', function() {
EventPluginHub.putListener(
getID(CHILD),
getInternal(CHILD),
ON_TOUCH_TAP_KEY,
recordID.bind(null, getID(CHILD))
recordID.bind(null, getInternal(CHILD))
);
ReactTestUtils.SimulateNative.touchStart(
CHILD,
@@ -364,14 +364,14 @@ describe('ReactBrowserEventEmitter', function() {
ReactTestUtils.nativeTouchData(0, tapMoveThreshold - 1)
);
expect(idCallOrder.length).toBe(1);
expect(idCallOrder[0]).toBe(getID(CHILD));
expect(idCallOrder[0]).toBe(getInternal(CHILD));
});
it('should not onTouchTap from when dragging beyond threshold', function() {
EventPluginHub.putListener(
getID(CHILD),
getInternal(CHILD),
ON_TOUCH_TAP_KEY,
recordID.bind(null, getID(CHILD))
recordID.bind(null, getInternal(CHILD))
);
ReactTestUtils.SimulateNative.touchStart(
CHILD,
@@ -426,19 +426,19 @@ describe('ReactBrowserEventEmitter', function() {
it('should bubble onTouchTap', function() {
EventPluginHub.putListener(
getID(CHILD),
getInternal(CHILD),
ON_TOUCH_TAP_KEY,
recordID.bind(null, getID(CHILD))
recordID.bind(null, getInternal(CHILD))
);
EventPluginHub.putListener(
getID(PARENT),
getInternal(PARENT),
ON_TOUCH_TAP_KEY,
recordID.bind(null, getID(PARENT))
recordID.bind(null, getInternal(PARENT))
);
EventPluginHub.putListener(
getID(GRANDPARENT),
getInternal(GRANDPARENT),
ON_TOUCH_TAP_KEY,
recordID.bind(null, getID(GRANDPARENT))
recordID.bind(null, getInternal(GRANDPARENT))
);
ReactTestUtils.SimulateNative.touchStart(
CHILD,
@@ -449,9 +449,9 @@ describe('ReactBrowserEventEmitter', function() {
ReactTestUtils.nativeTouchData(0, 0)
);
expect(idCallOrder.length).toBe(3);
expect(idCallOrder[0]).toBe(getID(CHILD));
expect(idCallOrder[1]).toBe(getID(PARENT));
expect(idCallOrder[2]).toBe(getID(GRANDPARENT));
expect(idCallOrder[0]).toBe(getInternal(CHILD));
expect(idCallOrder[1]).toBe(getInternal(PARENT));
expect(idCallOrder[2]).toBe(getInternal(GRANDPARENT));
});
});
@@ -213,7 +213,7 @@ var SelectEventPlugin = {
return null;
},
didPutListener: function(id, registrationName, listener) {
didPutListener: function(inst, registrationName, listener) {
if (registrationName === ON_SELECT_KEY) {
hasListener = true;
}
@@ -14,7 +14,7 @@
var EventConstants = require('EventConstants');
var EventListener = require('EventListener');
var EventPropagators = require('EventPropagators');
var ReactMount = require('ReactMount');
var ReactDOMComponentTree = require('ReactDOMComponentTree');
var SyntheticClipboardEvent = require('SyntheticClipboardEvent');
var SyntheticEvent = require('SyntheticEvent');
var SyntheticFocusEvent = require('SyntheticFocusEvent');
@@ -576,13 +576,14 @@ var SimpleEventPlugin = {
return event;
},
didPutListener: function(id, registrationName, listener) {
didPutListener: function(inst, registrationName, listener) {
// Mobile Safari does not fire properly bubble click events on
// non-interactive elements, which means delegated click listeners do not
// fire. The workaround for this bug involves attaching an empty click
// listener on the target node.
if (registrationName === ON_CLICK_KEY) {
var node = ReactMount.getNode(id);
var id = inst._rootNodeID;
var node = ReactDOMComponentTree.getNodeFromInstance(inst);
if (!onClickListeners[id]) {
onClickListeners[id] = EventListener.listen(
node,
@@ -593,8 +594,9 @@ var SimpleEventPlugin = {
}
},
willDeleteListener: function(id, registrationName) {
willDeleteListener: function(inst, registrationName) {
if (registrationName === ON_CLICK_KEY) {
var id = inst._rootNodeID;
onClickListeners[id].remove();
delete onClickListeners[id];
}
+14 -16
View File
@@ -61,8 +61,6 @@ var CHILDREN = keyOf({children: null});
var STYLE = keyOf({style: null});
var HTML = keyOf({__html: null});
var ELEMENT_NODE_TYPE = 1;
function getDeclarationErrorAddendum(internalInstance) {
if (internalInstance) {
var owner = internalInstance._currentElement._owner || null;
@@ -294,7 +292,7 @@ function assertValidProps(component, props) {
);
}
function enqueuePutListener(id, registrationName, listener, transaction) {
function enqueuePutListener(inst, registrationName, listener, transaction) {
if (__DEV__) {
// IE8 has no API for event capturing and the `onScroll` event doesn't
// bubble.
@@ -303,15 +301,15 @@ function enqueuePutListener(id, registrationName, listener, transaction) {
'This browser doesn\'t support the `onScroll` event'
);
}
var container = ReactMount.findReactContainerForID(id);
if (container) {
var doc = container.nodeType === ELEMENT_NODE_TYPE ?
container.ownerDocument :
container;
listenTo(registrationName, doc);
var containerInfo = inst._nativeContainerInfo;
if (!containerInfo) {
// Server rendering.
return;
}
var doc = containerInfo._ownerDocument;
listenTo(registrationName, doc);
transaction.getReactMountReady().enqueue(putListener, {
id: id,
inst: inst,
registrationName: registrationName,
listener: listener,
});
@@ -320,7 +318,7 @@ function enqueuePutListener(id, registrationName, listener, transaction) {
function putListener() {
var listenerToPut = this;
EventPluginHub.putListener(
listenerToPut.id,
listenerToPut.inst,
listenerToPut.registrationName,
listenerToPut.listener
);
@@ -729,7 +727,7 @@ ReactDOMComponent.Mixin = {
}
if (registrationNameModules.hasOwnProperty(propKey)) {
if (propValue) {
enqueuePutListener(this._rootNodeID, propKey, propValue, transaction);
enqueuePutListener(this, propKey, propValue, transaction);
}
} else {
if (propKey === STYLE) {
@@ -957,7 +955,7 @@ ReactDOMComponent.Mixin = {
// Only call deleteListener if there was a listener previously or
// else willDeleteListener gets called when there wasn't actually a
// listener (e.g., onClick={null})
deleteListener(this._rootNodeID, propKey);
deleteListener(this, propKey);
}
} else if (
DOMProperty.properties[propKey] ||
@@ -1012,9 +1010,9 @@ ReactDOMComponent.Mixin = {
}
} else if (registrationNameModules.hasOwnProperty(propKey)) {
if (nextProp) {
enqueuePutListener(this._rootNodeID, propKey, nextProp, transaction);
enqueuePutListener(this, propKey, nextProp, transaction);
} else if (lastProp) {
deleteListener(this._rootNodeID, propKey);
deleteListener(this, propKey);
}
} else if (isCustomComponent(this._tag, nextProps)) {
if (propKey === CHILDREN) {
@@ -1147,7 +1145,7 @@ ReactDOMComponent.Mixin = {
ReactDOMComponentTree.uncacheNode(this);
this.unmountChildren();
EventPluginHub.deleteAllListeners(this._rootNodeID);
EventPluginHub.deleteAllListeners(this);
ReactComponentBrowserEnvironment.unmountIDFromEnvironment(this._rootNodeID);
this._rootNodeID = null;
this._wrapperState = null;
@@ -843,7 +843,7 @@ describe('ReactDOMComponent', function() {
describe('unmountComponent', function() {
it('should clean up listeners', function() {
var EventPluginHub = require('EventPluginHub');
var ReactMount = require('ReactMount');
var ReactDOMComponentTree = require('ReactDOMComponentTree');
var container = document.createElement('div');
document.body.appendChild(container);
@@ -853,16 +853,16 @@ describe('ReactDOMComponent', function() {
instance = ReactDOM.render(instance, container);
var rootNode = ReactDOM.findDOMNode(instance);
var rootNodeID = ReactMount.getID(rootNode);
var inst = ReactDOMComponentTree.getInstanceFromNode(rootNode);
expect(
EventPluginHub.getListener(rootNodeID, 'onClick')
EventPluginHub.getListener(inst, 'onClick')
).toBe(callback);
expect(rootNode).toBe(ReactDOM.findDOMNode(instance));
ReactDOM.unmountComponentAtNode(container);
expect(
EventPluginHub.getListener(rootNodeID, 'onClick')
EventPluginHub.getListener(inst, 'onClick')
).toBe(undefined);
});
});
+12 -12
View File
@@ -102,7 +102,7 @@ var EventPluginHub = {
* @param {string} registrationName Name of listener (e.g. `onClick`).
* @param {?function} listener The callback to store.
*/
putListener: function(id, registrationName, listener) {
putListener: function(inst, registrationName, listener) {
invariant(
typeof listener === 'function',
'Expected %s listener to be a function, instead got type %s',
@@ -111,12 +111,12 @@ var EventPluginHub = {
var bankForRegistrationName =
listenerBank[registrationName] || (listenerBank[registrationName] = {});
bankForRegistrationName[id] = listener;
bankForRegistrationName[inst._rootNodeID] = listener;
var PluginModule =
EventPluginRegistry.registrationNameModules[registrationName];
if (PluginModule && PluginModule.didPutListener) {
PluginModule.didPutListener(id, registrationName, listener);
PluginModule.didPutListener(inst, registrationName, listener);
}
},
@@ -125,9 +125,9 @@ var EventPluginHub = {
* @param {string} registrationName Name of listener (e.g. `onClick`).
* @return {?function} The stored callback.
*/
getListener: function(id, registrationName) {
getListener: function(inst, registrationName) {
var bankForRegistrationName = listenerBank[registrationName];
return bankForRegistrationName && bankForRegistrationName[id];
return bankForRegistrationName && bankForRegistrationName[inst._rootNodeID];
},
/**
@@ -136,17 +136,17 @@ var EventPluginHub = {
* @param {string} id ID of the DOM element.
* @param {string} registrationName Name of listener (e.g. `onClick`).
*/
deleteListener: function(id, registrationName) {
deleteListener: function(inst, registrationName) {
var PluginModule =
EventPluginRegistry.registrationNameModules[registrationName];
if (PluginModule && PluginModule.willDeleteListener) {
PluginModule.willDeleteListener(id, registrationName);
PluginModule.willDeleteListener(inst, registrationName);
}
var bankForRegistrationName = listenerBank[registrationName];
// TODO: This should never be null -- when is it?
if (bankForRegistrationName) {
delete bankForRegistrationName[id];
delete bankForRegistrationName[inst._rootNodeID];
}
},
@@ -155,19 +155,19 @@ var EventPluginHub = {
*
* @param {string} id ID of the DOM element.
*/
deleteAllListeners: function(id) {
deleteAllListeners: function(inst) {
for (var registrationName in listenerBank) {
if (!listenerBank[registrationName][id]) {
if (!listenerBank[registrationName][inst._rootNodeID]) {
continue;
}
var PluginModule =
EventPluginRegistry.registrationNameModules[registrationName];
if (PluginModule && PluginModule.willDeleteListener) {
PluginModule.willDeleteListener(id, registrationName);
PluginModule.willDeleteListener(inst, registrationName);
}
delete listenerBank[registrationName][id];
delete listenerBank[registrationName][inst._rootNodeID];
}
},
@@ -29,7 +29,7 @@ var getListener = EventPluginHub.getListener;
function listenerAtPhase(inst, event, propagationPhase) {
var registrationName =
event.dispatchConfig.phasedRegistrationNames[propagationPhase];
return getListener(inst._rootNodeID, registrationName);
return getListener(inst, registrationName);
}
/**
@@ -96,7 +96,7 @@ function accumulateTwoPhaseDispatchesSingleSkipTarget(event) {
function accumulateDispatches(inst, ignoredDirection, event) {
if (event && event.dispatchConfig.registrationName) {
var registrationName = event.dispatchConfig.registrationName;
var listener = getListener(inst._rootNodeID, registrationName);
var listener = getListener(inst, registrationName);
if (listener) {
event._dispatchListeners =
accumulateInto(event._dispatchListeners, listener);
@@ -237,7 +237,7 @@ var registerTestHandlers = function(eventTestConfig, readableIDToID) {
}
return nodeConfig.returnVal;
}.bind(null, readableID, nodeConfig);
EventPluginHub.putListener(id, registrationName, handler);
EventPluginHub.putListener(idToInstance[id], registrationName, handler);
}
};
/*eslint-enable no-loop-func, no-shadow */
+3 -1
View File
@@ -203,7 +203,9 @@ var ReactDefaultPerf = {
} else {
// basic format
var id = args[0];
if (typeof id === 'object') {
if (moduleName === 'EventPluginHub') {
id = id._rootNodeID;
} else if (typeof id === 'object') {
id = ReactMount.getID(args[0]);
}
ReactDefaultPerf._recordWrite(