Revert "Simulate input event" for now

This reverts commit 580e8f0dbb.
This commit is contained in:
Ben Alpert
2013-06-04 01:29:12 -07:00
parent 580e8f0dbb
commit 35306fa7f5
6 changed files with 9 additions and 108 deletions
+1 -3
View File
@@ -24,7 +24,6 @@ var ReactDOMForm = require('ReactDOMForm');
var DefaultEventPluginOrder = require('DefaultEventPluginOrder');
var EnterLeaveEventPlugin = require('EnterLeaveEventPlugin');
var EventPluginHub = require('EventPluginHub');
var InputEventPlugin = require('InputEventPlugin');
var ReactInstanceHandles = require('ReactInstanceHandles');
var SimpleEventPlugin = require('SimpleEventPlugin');
@@ -41,8 +40,7 @@ function inject() {
*/
EventPluginHub.injection.injectEventPluginsByName({
'SimpleEventPlugin': SimpleEventPlugin,
'EnterLeaveEventPlugin': EnterLeaveEventPlugin,
'InputEventPlugin': InputEventPlugin
'EnterLeaveEventPlugin': EnterLeaveEventPlugin
});
/*
+1 -3
View File
@@ -211,10 +211,8 @@ function listenAtTopLevel(touchNotMouse) {
trapBubbledEvent(topLevelTypes.topKeyUp, 'keyup', mountAt);
trapBubbledEvent(topLevelTypes.topKeyPress, 'keypress', mountAt);
trapBubbledEvent(topLevelTypes.topKeyDown, 'keydown', mountAt);
trapBubbledEvent(topLevelTypes.topChange, 'change', mountAt);
trapBubbledEvent(topLevelTypes.topInput, 'input', mountAt);
trapBubbledEvent(topLevelTypes.topCut, 'cut', mountAt);
trapBubbledEvent(topLevelTypes.topPaste, 'paste', mountAt);
trapBubbledEvent(topLevelTypes.topChange, 'change', mountAt);
trapBubbledEvent(
topLevelTypes.topDOMCharacterDataModified,
'DOMCharacterDataModified',
-2
View File
@@ -29,7 +29,6 @@ var topLevelTypes = keyMirror({
topBlur: null,
topChange: null,
topClick: null,
topCut: null,
topDOMCharacterDataModified: null,
topDoubleClick: null,
topFocus: null,
@@ -43,7 +42,6 @@ var topLevelTypes = keyMirror({
topMouseOver: null,
topMouseUp: null,
topMouseWheel: null,
topPaste: null,
topScroll: null,
topSubmit: null,
topTouchCancel: null,
@@ -34,7 +34,6 @@ var DefaultEventPluginOrder = [
keyOf({SimpleEventPlugin: null}),
keyOf({TapEventPlugin: null}),
keyOf({EnterLeaveEventPlugin: null}),
keyOf({InputEventPlugin: null}),
keyOf({AnalyticsEventPlugin: null})
];
-99
View File
@@ -1,99 +0,0 @@
/**
* Copyright 2013 Facebook, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
* @providesModule InputEventPlugin
*/
"use strict";
var AbstractEvent = require('AbstractEvent');
var EventConstants = require('EventConstants');
var EventPluginUtils = require('EventPluginUtils');
var EventPropagators = require('EventPropagators');
var keyOf = require('keyOf');
var topLevelTypes = EventConstants.topLevelTypes;
var abstractEventTypes = {
input: {
phasedRegistrationNames: {
bubbled: keyOf({onInput: null}),
captured: keyOf({onInputCapture: null})
}
}
};
/**
* @see EventPluginHub.extractAbstractEvents
*/
var extractAbstractEvents = function(
topLevelType,
nativeEvent,
renderedTargetID,
renderedTarget) {
var defer, key;
switch (topLevelType) {
case topLevelTypes.topInput:
// When the native input event is triggered, we definitely want to
// forward it along. However, IE9's input event doesn't get triggered
// when deleting text, and IE8 doesn't support input at all, so we
// simulate it on change, cut, paste, and keydown.
case topLevelTypes.topChange:
defer = false;
break;
case topLevelTypes.topCut:
case topLevelTypes.topPaste:
defer = true;
break;
case topLevelTypes.topKeyDown:
key = nativeEvent.keyCode;
// Ignore command, modifiers, and arrow keys, respectively
if (key === 91 || (15 < key && key < 19) || (37 <= key && key <= 40)) {
return;
}
defer = true;
break;
default:
return;
}
var type = abstractEventTypes.input;
var abstractTargetID = renderedTargetID;
var abstractEvent = AbstractEvent.getPooled(
type,
abstractTargetID,
topLevelType,
nativeEvent
);
EventPropagators.accumulateTwoPhaseDispatches(abstractEvent);
if (defer) {
setTimeout(function() {
EventPluginHub.enqueueAbstractEvents(abstractEvent);
EventPluginHub.processAbstractEventQueue();
}, 0);
} else {
return abstractEvent;
}
};
var InputEventPlugin = {
abstractEventTypes: abstractEventTypes,
extractAbstractEvents: extractAbstractEvents
};
module.exports = InputEventPlugin;
+7
View File
@@ -108,6 +108,12 @@ var SimpleEventPlugin = {
captured: keyOf({onKeyDownCapture: true})
}
},
input: {
phasedRegistrationNames: {
bubbled: keyOf({onInput: true}),
captured: keyOf({onInputCapture: true})
}
},
focus: {
phasedRegistrationNames: {
bubbled: keyOf({onFocus: true}),
@@ -220,6 +226,7 @@ SimpleEventPlugin.topLevelTypesToAbstract = {
topKeyUp: SimpleEventPlugin.abstractEventTypes.keyUp,
topKeyPress: SimpleEventPlugin.abstractEventTypes.keyPress,
topKeyDown: SimpleEventPlugin.abstractEventTypes.keyDown,
topInput: SimpleEventPlugin.abstractEventTypes.input,
topFocus: SimpleEventPlugin.abstractEventTypes.focus,
topBlur: SimpleEventPlugin.abstractEventTypes.blur,
topScroll: SimpleEventPlugin.abstractEventTypes.scroll,