Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
Download
81155 views
1
/**
2
* Copyright 2013-2014, 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 SyntheticUIEvent
10
* @typechecks static-only
11
*/
12
13
"use strict";
14
15
var SyntheticEvent = require('SyntheticEvent');
16
17
var getEventTarget = require('getEventTarget');
18
19
/**
20
* @interface UIEvent
21
* @see http://www.w3.org/TR/DOM-Level-3-Events/
22
*/
23
var UIEventInterface = {
24
view: function(event) {
25
if (event.view) {
26
return event.view;
27
}
28
29
var target = getEventTarget(event);
30
if (target != null && target.window === target) {
31
// target is a window object
32
return target;
33
}
34
35
var doc = target.ownerDocument;
36
// TODO: Figure out why `ownerDocument` is sometimes undefined in IE8.
37
if (doc) {
38
return doc.defaultView || doc.parentWindow;
39
} else {
40
return window;
41
}
42
},
43
detail: function(event) {
44
return event.detail || 0;
45
}
46
};
47
48
/**
49
* @param {object} dispatchConfig Configuration used to dispatch this event.
50
* @param {string} dispatchMarker Marker identifying the event target.
51
* @param {object} nativeEvent Native browser event.
52
* @extends {SyntheticEvent}
53
*/
54
function SyntheticUIEvent(dispatchConfig, dispatchMarker, nativeEvent) {
55
SyntheticEvent.call(this, dispatchConfig, dispatchMarker, nativeEvent);
56
}
57
58
SyntheticEvent.augmentClass(SyntheticUIEvent, UIEventInterface);
59
60
module.exports = SyntheticUIEvent;
61
62