Skip to content

Commit

Permalink
Remove IE8-specific ChangeEventPlugin logic (facebook#9281)
Browse files Browse the repository at this point in the history
  • Loading branch information
aweary authored Mar 29, 2017
1 parent da91e9e commit 9a93be0
Showing 1 changed file with 1 addition and 41 deletions.
42 changes: 1 addition & 41 deletions src/renderers/dom/shared/eventPlugins/ChangeEventPlugin.js
Original file line number Diff line number Diff line change
Expand Up @@ -71,13 +71,6 @@ function shouldUseChangeEvent(elem) {
(nodeName === 'input' && elem.type === 'file');
}

var doesChangeEventBubble = false;
if (ExecutionEnvironment.canUseDOM) {
// See `handleChange` comment below
doesChangeEventBubble = isEventSupported('change') &&
(!document.documentMode || document.documentMode > 8);
}

function manualDispatchChangeEvent(nativeEvent) {
var event = createAndAccumulateChangeEvent(
activeElementInst,
Expand All @@ -104,21 +97,6 @@ function runEventInBatch(event) {
EventPluginHub.processEventQueue(false);
}

function startWatchingForChangeEventIE8(target, targetInst) {
activeElement = target;
activeElementInst = targetInst;
activeElement.attachEvent('onchange', manualDispatchChangeEvent);
}

function stopWatchingForChangeEventIE8() {
if (!activeElement) {
return;
}
activeElement.detachEvent('onchange', manualDispatchChangeEvent);
activeElement = null;
activeElementInst = null;
}

function getInstIfValueChanged(targetInst) {
if (inputValueTracking.updateValueIfChanged(targetInst)) {
return targetInst;
Expand All @@ -131,17 +109,6 @@ function getTargetInstForChangeEvent(topLevelType, targetInst) {
}
}

function handleEventsForChangeEventIE8(topLevelType, target, targetInst) {
if (topLevelType === 'topFocus') {
// stopWatching() should be a noop here but we call it just in case we
// missed a blur event somehow.
stopWatchingForChangeEventIE8();
startWatchingForChangeEventIE8(target, targetInst);
} else if (topLevelType === 'topBlur') {
stopWatchingForChangeEventIE8();
}
}

/**
* SECTION: handle `input` event
*/
Expand Down Expand Up @@ -192,9 +159,6 @@ function handlePropertyChange(nativeEvent) {

function handleEventsForInputEventPolyfill(topLevelType, target, targetInst) {
if (topLevelType === 'topFocus') {
// In IE8, we can capture almost all .value changes by adding a
// propertychange handler and looking for events with propertyName
// equal to 'value'
// In IE9, propertychange fires for most input events but is buggy and
// doesn't fire when text is deleted, but conveniently, selectionchange
// appears to fire in all of the remaining cases so we catch those and
Expand Down Expand Up @@ -305,11 +269,7 @@ var ChangeEventPlugin = {

var getTargetInstFunc, handleEventFunc;
if (shouldUseChangeEvent(targetNode)) {
if (doesChangeEventBubble) {
getTargetInstFunc = getTargetInstForChangeEvent;
} else {
handleEventFunc = handleEventsForChangeEventIE8;
}
getTargetInstFunc = getTargetInstForChangeEvent;
} else if (isTextInputElement(targetNode)) {
if (isInputEventSupported) {
getTargetInstFunc = getTargetInstForInputOrChangeEvent;
Expand Down

0 comments on commit 9a93be0

Please sign in to comment.