Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
Download
80517 views
1
/**
2
* Copyright 2013-2015, Facebook, Inc.
3
* All rights reserved.
4
*
5
* This source code is licensed under the BSD-style license found in the
6
* LICENSE file in the root directory of this source tree. An additional grant
7
* of patent rights can be found in the PATENTS file in the same directory.
8
*
9
* @providesModule MobileSafariClickEventPlugin
10
* @typechecks static-only
11
*/
12
13
'use strict';
14
15
var EventConstants = require("./EventConstants");
16
17
var emptyFunction = require("./emptyFunction");
18
19
var topLevelTypes = EventConstants.topLevelTypes;
20
21
/**
22
* Mobile Safari does not fire properly bubble click events on non-interactive
23
* elements, which means delegated click listeners do not fire. The workaround
24
* for this bug involves attaching an empty click listener on the target node.
25
*
26
* This particular plugin works around the bug by attaching an empty click
27
* listener on `touchstart` (which does fire on every element).
28
*/
29
var MobileSafariClickEventPlugin = {
30
31
eventTypes: null,
32
33
/**
34
* @param {string} topLevelType Record from `EventConstants`.
35
* @param {DOMEventTarget} topLevelTarget The listening component root node.
36
* @param {string} topLevelTargetID ID of `topLevelTarget`.
37
* @param {object} nativeEvent Native browser event.
38
* @return {*} An accumulation of synthetic events.
39
* @see {EventPluginHub.extractEvents}
40
*/
41
extractEvents: function(
42
topLevelType,
43
topLevelTarget,
44
topLevelTargetID,
45
nativeEvent) {
46
if (topLevelType === topLevelTypes.topTouchStart) {
47
var target = nativeEvent.target;
48
if (target && !target.onclick) {
49
target.onclick = emptyFunction;
50
}
51
}
52
}
53
54
};
55
56
module.exports = MobileSafariClickEventPlugin;
57
58