Skip to content

Commit

Permalink
Revert facebook#1536
Browse files Browse the repository at this point in the history
It's causing issues in product code. Reverting until it can be
investigated further.
  • Loading branch information
yungsters authored and zpao committed Jun 15, 2014
1 parent 0f7423f commit 431155d
Show file tree
Hide file tree
Showing 6 changed files with 67 additions and 67 deletions.
3 changes: 2 additions & 1 deletion src/browser/eventPlugins/DefaultEventPluginOrder.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,8 @@ var DefaultEventPluginOrder = [
keyOf({SelectEventPlugin: null}),
keyOf({CompositionEventPlugin: null}),
keyOf({BeforeInputEventPlugin: null}),
keyOf({AnalyticsEventPlugin: null})
keyOf({AnalyticsEventPlugin: null}),
keyOf({MobileSafariClickEventPlugin: null})
];

module.exports = DefaultEventPluginOrder;
63 changes: 63 additions & 0 deletions src/browser/eventPlugins/MobileSafariClickEventPlugin.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
/**
* Copyright 2013-2014 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 MobileSafariClickEventPlugin
* @typechecks static-only
*/

"use strict";

var EventConstants = require('EventConstants');

var emptyFunction = require('emptyFunction');

var topLevelTypes = EventConstants.topLevelTypes;

/**
* 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.
*
* This particular plugin works around the bug by attaching an empty click
* listener on `touchstart` (which does fire on every element).
*/
var MobileSafariClickEventPlugin = {

eventTypes: null,

/**
* @param {string} topLevelType Record from `EventConstants`.
* @param {DOMEventTarget} topLevelTarget The listening component root node.
* @param {string} topLevelTargetID ID of `topLevelTarget`.
* @param {object} nativeEvent Native browser event.
* @return {*} An accumulation of synthetic events.
* @see {EventPluginHub.extractEvents}
*/
extractEvents: function(
topLevelType,
topLevelTarget,
topLevelTargetID,
nativeEvent) {
if (topLevelType === topLevelTypes.topTouchStart) {
var target = nativeEvent.target;
if (target && !target.onclick) {
target.onclick = emptyFunction;
}
}
}

};

module.exports = MobileSafariClickEventPlugin;
23 changes: 0 additions & 23 deletions src/browser/eventPlugins/SimpleEventPlugin.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,8 @@
"use strict";

var EventConstants = require('EventConstants');
var EventListener = require('EventListener');
var EventPluginUtils = require('EventPluginUtils');
var EventPropagators = require('EventPropagators');
var ReactMount = require('ReactMount');
var SyntheticClipboardEvent = require('SyntheticClipboardEvent');
var SyntheticEvent = require('SyntheticEvent');
var SyntheticFocusEvent = require('SyntheticFocusEvent');
Expand All @@ -33,7 +31,6 @@ var SyntheticTouchEvent = require('SyntheticTouchEvent');
var SyntheticUIEvent = require('SyntheticUIEvent');
var SyntheticWheelEvent = require('SyntheticWheelEvent');

var emptyFunction = require('emptyFunction');
var invariant = require('invariant');
var keyOf = require('keyOf');

Expand Down Expand Up @@ -296,9 +293,6 @@ for (var topLevelType in topLevelEventsToDispatchConfig) {
topLevelEventsToDispatchConfig[topLevelType].dependencies = [topLevelType];
}

var ON_CLICK_KEY = keyOf({onClick: null});
var onClickListeners = {};

var SimpleEventPlugin = {

eventTypes: eventTypes,
Expand Down Expand Up @@ -418,23 +412,6 @@ var SimpleEventPlugin = {
);
EventPropagators.accumulateTwoPhaseDispatches(event);
return event;
},

didPutListener: function(id, 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);
onClickListeners[id] = EventListener.listen(node, 'click', emptyFunction);
}
},

willDeleteListener: function(id, registrationName) {
if (registrationName === ON_CLICK_KEY) {
onClickListeners[id].remove();
}
}

};
Expand Down
2 changes: 2 additions & 0 deletions src/browser/ui/ReactDefaultInjection.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ var DefaultEventPluginOrder = require('DefaultEventPluginOrder');
var EnterLeaveEventPlugin = require('EnterLeaveEventPlugin');
var ExecutionEnvironment = require('ExecutionEnvironment');
var HTMLDOMPropertyConfig = require('HTMLDOMPropertyConfig');
var MobileSafariClickEventPlugin = require('MobileSafariClickEventPlugin');
var ReactBrowserComponentMixin = require('ReactBrowserComponentMixin');
var ReactComponentBrowserEnvironment =
require('ReactComponentBrowserEnvironment');
Expand Down Expand Up @@ -70,6 +71,7 @@ function inject() {
EnterLeaveEventPlugin: EnterLeaveEventPlugin,
ChangeEventPlugin: ChangeEventPlugin,
CompositionEventPlugin: CompositionEventPlugin,
MobileSafariClickEventPlugin: MobileSafariClickEventPlugin,
SelectEventPlugin: SelectEventPlugin,
BeforeInputEventPlugin: BeforeInputEventPlugin
});
Expand Down
20 changes: 0 additions & 20 deletions src/browser/ui/__tests__/ReactDOMComponent-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -348,26 +348,6 @@ describe('ReactDOMComponent', function() {
'properties to values, not a string.'
);
});

it("should execute custom event plugin listening behavior", function() {
var React = require('React');
var SimpleEventPlugin = require('SimpleEventPlugin');

SimpleEventPlugin.didPutListener = mocks.getMockFunction();
SimpleEventPlugin.willDeleteListener = mocks.getMockFunction();

var container = document.createElement('div');
React.renderComponent(
<div onClick={() => true} />,
container
);

expect(SimpleEventPlugin.didPutListener.mock.calls.length).toBe(1);

React.unmountComponentAtNode(container);

expect(SimpleEventPlugin.willDeleteListener.mock.calls.length).toBe(1);
});
});

describe('updateComponent', function() {
Expand Down
23 changes: 0 additions & 23 deletions src/event/EventPluginHub.js
Original file line number Diff line number Diff line change
Expand Up @@ -171,12 +171,6 @@ var EventPluginHub = {
var bankForRegistrationName =
listenerBank[registrationName] || (listenerBank[registrationName] = {});
bankForRegistrationName[id] = listener;

var PluginModule =
EventPluginRegistry.registrationNameModules[registrationName];
if (PluginModule && PluginModule.didPutListener) {
PluginModule.didPutListener(id, registrationName, listener);
}
},

/**
Expand All @@ -196,14 +190,7 @@ var EventPluginHub = {
* @param {string} registrationName Name of listener (e.g. `onClick`).
*/
deleteListener: function(id, registrationName) {
var PluginModule =
EventPluginRegistry.registrationNameModules[registrationName];
if (PluginModule && PluginModule.willDeleteListener) {
PluginModule.willDeleteListener(id, registrationName);
}

var bankForRegistrationName = listenerBank[registrationName];
// TODO: This should never be null -- when is it?
if (bankForRegistrationName) {
delete bankForRegistrationName[id];
}
Expand All @@ -216,16 +203,6 @@ var EventPluginHub = {
*/
deleteAllListeners: function(id) {
for (var registrationName in listenerBank) {
if (!listenerBank[registrationName][id]) {
continue;
}

var PluginModule =
EventPluginRegistry.registrationNameModules[registrationName];
if (PluginModule && PluginModule.willDeleteListener) {
PluginModule.willDeleteListener(id, registrationName);
}

delete listenerBank[registrationName][id];
}
},
Expand Down

0 comments on commit 431155d

Please sign in to comment.