-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
90 lines (73 loc) · 1.71 KB
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
/**
* Module exports.
*/
module.exports = Event;
/**
* Constants.
*/
var NONE = 0;
var CAPTURING_PHASE = 1;
var AT_TARGET = 2;
var BUBBLING_PHASE = 3;
/**
* `Event` constructor.
*
* @api public
*/
function Event (type) {
if (!(this instanceof Event)) throw new TypeError('DOM object constructor cannot be called as a function.');
if (0 == arguments.length) throw new TypeError('Not enough arguments');
this.bubbles = false;
this.cancelBubble = false;
this.cancelable = false;
this.currentTarget = null;
this.defaultPrevented = false;
this.eventPhase = NONE;
this.returnValue = true;
this.srcElement = null;
this.target = null;
this.timeStamp = +new Date();
this.type = String(type);
}
/**
* Expose constants.
*/
Event.NONE = Event.prototype.NONE = NONE;
Event.CAPTURING_PHASE = Event.prototype.CAPTURING_PHASE = CAPTURING_PHASE;
Event.AT_TARGET = Event.prototype.AT_TARGET = AT_TARGET;
Event.BUBBLING_PHASE = Event.prototype.BUBBLING_PHASE = BUBBLING_PHASE;
/**
* Initializes the `type`, `bubbles`, and `cancelable` properties
* for this Event instance.
*
* @api public
*/
function initEvent (type, bubbles, cancelable) {
this.type = String(type);
this.bubbles = Boolean(bubbles);
this.cancelable = Boolean(cancelable);
}
/**
* Cancels the event (if it is cancelable).
*
* @api public
*/
function preventDefault () {
if (this.cancelable) {
this.defaultPrevented = true;
}
}
/**
*
*/
function stopImmediatePropagation () {
}
/**
*
*/
function stopPropagation () {
}
Event.prototype.initEvent = initEvent;
Event.prototype.preventDefault = preventDefault;
Event.prototype.stopImmediatePropagation = stopImmediatePropagation;
Event.prototype.stopPropagation = stopPropagation;