@samitouri / QOS-React-2 / commits / b3e0dc47a8
Fork 0

The library for web and native user interfaces.

Rename "Delegate" to "Synthetic"

This is just a simple rename of the event classes to `SyntheticEvent`. I've also updated the constructor arguments to be more correct: - `dispatchConfig`: Data used by the plugin system for dispatching the event, for example: `{registrationName: 'onClick'}` - `dispatchMarker`: An identifying marker used to describe where the event is occuring, for example: `.reactRoot[0]`

CommitSyncScript committed Jun 10, 2013 at 16:16 UTC b3e0dc47a87220fd3e7a69d14b5a3556e2a834f3
17 files changed +328 -325
src/event/delegate/DelegateFocusEvent.js deleted
-28
@@ -1,28 +0,0 @@
1 -/**
2 - * @providesModule DelegateFocusEvent
3 - * @typechecks
4 - */
5 -
6 -var DelegateUIEvent = require('DelegateUIEvent');
7 -
8 -/**
9 - * @interface FocusEvent
10 - * @see http://www.w3.org/TR/DOM-Level-3-Events/
11 - */
12 -var FocusEventInterface = {
13 - relatedTarget: null
14 -};
15 -
16 -/**
17 - * @param {object} reactEventType See `EventPluginHub`.
18 - * @param {string} reactTargetID ID of the target component.
19 - * @param {object} nativeEvent Native browser event.
20 - * @extends {DelegateUIEvent}
21 - */
22 -function DelegateFocusEvent(reactEventType, reactTargetID, nativeEvent) {
23 - DelegateUIEvent.call(this, reactEventType, reactTargetID, nativeEvent);
24 -}
25 -
26 -DelegateUIEvent.augmentClass(DelegateFocusEvent, FocusEventInterface);
27 -
28 -module.exports = DelegateFocusEvent;
src/event/delegate/DelegateKeyboardEvent.js deleted
-40
@@ -1,40 +0,0 @@
1 -/**
2 - * @providesModule DelegateKeyboardEvent
3 - * @typechecks
4 - */
5 -
6 -var DelegateUIEvent = require('DelegateUIEvent');
7 -
8 -/**
9 - * @interface KeyboardEvent
10 - * @see http://www.w3.org/TR/DOM-Level-3-Events/
11 - */
12 -var KeyboardEventInterface = {
13 - char: null,
14 - key: null,
15 - location: null,
16 - ctrlKey: null,
17 - shiftKey: null,
18 - altKey: null,
19 - metaKey: null,
20 - repeat: null,
21 - locale: null,
22 - // Legacy Interface
23 - charCode: null,
24 - keyCode: null,
25 - which: null
26 -};
27 -
28 -/**
29 - * @param {object} reactEventType See `EventPluginHub`.
30 - * @param {string} reactTargetID ID of the target component.
31 - * @param {object} nativeEvent Native browser event.
32 - * @extends {DelegateUIEvent}
33 - */
34 -function DelegateKeyboardEvent(reactEventType, reactTargetID, nativeEvent) {
35 - DelegateUIEvent.call(this, reactEventType, reactTargetID, nativeEvent);
36 -}
37 -
38 -DelegateUIEvent.augmentClass(DelegateKeyboardEvent, KeyboardEventInterface);
39 -
40 -module.exports = DelegateKeyboardEvent;
src/event/delegate/DelegateMutationEvent.js deleted
-32
@@ -1,32 +0,0 @@
1 -/**
2 - * @providesModule DelegateMutationEvent
3 - * @typechecks
4 - */
5 -
6 -var DelegateEvent = require('DelegateEvent');
7 -
8 -/**
9 - * @interface MutationEvent
10 - * @see http://www.w3.org/TR/DOM-Level-3-Events/
11 - */
12 -var MutationEventInterface = {
13 - relatedNode: null,
14 - prevValue: null,
15 - newValue: null,
16 - attrName: null,
17 - attrChange: null
18 -};
19 -
20 -/**
21 - * @param {object} reactEventType See `EventPluginHub`.
22 - * @param {string} reactTargetID ID of the target component.
23 - * @param {object} nativeEvent Native browser event.
24 - * @extends {DelegateEvent}
25 - */
26 -function DelegateMutationEvent(reactEventType, reactTargetID, nativeEvent) {
27 - DelegateEvent.call(this, reactEventType, reactTargetID, nativeEvent);
28 -}
29 -
30 -DelegateEvent.augmentClass(DelegateMutationEvent, MutationEventInterface);
31 -
32 -module.exports = DelegateMutationEvent;
src/event/delegate/DelegateTouchEvent.js deleted
-34
@@ -1,34 +0,0 @@
1 -/**
2 - * @providesModule DelegateTouchEvent
3 - * @typechecks
4 - */
5 -
6 -var DelegateUIEvent = require('DelegateUIEvent');
7 -
8 -/**
9 - * @interface TouchEvent
10 - * @see http://www.w3.org/TR/DOM-Level-3-Events/
11 - */
12 -var TouchEventInterface = {
13 - touches: null,
14 - targetTouches: null,
15 - changedTouches: null,
16 - altKey: null,
17 - metaKey: null,
18 - ctrlKey: null,
19 - shiftKey: null
20 -};
21 -
22 -/**
23 - * @param {object} reactEventType See `EventPluginHub`.
24 - * @param {string} reactTargetID ID of the target component.
25 - * @param {object} nativeEvent Native browser event.
26 - * @extends {DelegateUIEvent}
27 - */
28 -function DelegateTouchEvent(reactEventType, reactTargetID, nativeEvent) {
29 - DelegateUIEvent.call(this, reactEventType, reactTargetID, nativeEvent);
30 -}
31 -
32 -DelegateUIEvent.augmentClass(DelegateTouchEvent, TouchEventInterface);
33 -
34 -module.exports = DelegateTouchEvent;
src/event/delegate/DelegateUIEvent.js deleted
-29
@@ -1,29 +0,0 @@
1 -/**
2 - * @providesModule DelegateUIEvent
3 - * @typechecks
4 - */
5 -
6 -var DelegateEvent = require('DelegateEvent');
7 -
8 -/**
9 - * @interface UIEvent
10 - * @see http://www.w3.org/TR/DOM-Level-3-Events/
11 - */
12 -var UIEventInterface = {
13 - view: null,
14 - detail: null
15 -};
16 -
17 -/**
18 - * @param {object} delegateConfig Configuration used by top-level delegation.
19 - * @param {string} delegateMarker Marker identifying the event target.
20 - * @param {object} nativeEvent Native browser event.
21 - * @extends {DelegateEvent}
22 - */
23 -function DelegateUIEvent(delegateConfig, delegateMarker, nativeEvent) {
24 - DelegateEvent.call(this, delegateConfig, delegateMarker, nativeEvent);
25 -}
26 -
27 -DelegateEvent.augmentClass(DelegateUIEvent, UIEventInterface);
28 -
29 -module.exports = DelegateUIEvent;
src/event/delegate/__tests__/DelegateEvent-test.js deleted
-65
@@ -1,65 +0,0 @@
1 -/**
2 - * @emails react-core
3 - */
4 -
5 -"use strict";
6 -
7 -var DelegateEvent;
8 -
9 -describe('DelegateEvent', function() {
10 - var delegate;
11 -
12 - beforeEach(function() {
13 - DelegateEvent = require('DelegateEvent');
14 -
15 - delegate = function(nativeEvent) {
16 - return DelegateEvent.getPooled({}, '', nativeEvent);
17 - };
18 - });
19 -
20 - it('should normalize `target` from the nativeEvent', function() {
21 - var target = document.createElement('div');
22 - var delegateEvent = delegate({srcElement: target});
23 -
24 - expect(delegateEvent.target).toBe(target);
25 - expect(delegateEvent.type).toBe(undefined);
26 - });
27 -
28 - it('should be able to `preventDefault`', function() {
29 - var nativeEvent = {};
30 - var delegateEvent = delegate(nativeEvent);
31 -
32 - expect(delegateEvent.isDefaultPrevented()).toBe(false);
33 - delegateEvent.preventDefault();
34 - expect(delegateEvent.isDefaultPrevented()).toBe(true);
35 -
36 - expect(delegateEvent.defaultPrevented).toBe(true);
37 -
38 - expect(nativeEvent.returnValue).toBe(false);
39 - });
40 -
41 - it('should be prevented if nativeEvent is prevented', function() {
42 - expect(delegate({defaultPrevented: true}).isDefaultPrevented()).toBe(true);
43 - expect(delegate({returnValue: false}).isDefaultPrevented()).toBe(true);
44 - });
45 -
46 - it('should be able to `stopPropagation`', function() {
47 - var nativeEvent = {};
48 - var delegateEvent = delegate(nativeEvent);
49 -
50 - expect(delegateEvent.isPropagationStopped()).toBe(false);
51 - delegateEvent.stopPropagation();
52 - expect(delegateEvent.isPropagationStopped()).toBe(true);
53 -
54 - expect(nativeEvent.cancelBubble).toBe(true);
55 - });
56 -
57 - it('should be able to `persist`', function() {
58 - var delegateEvent = delegate({});
59 -
60 - expect(delegateEvent.isPersistent()).toBe(false);
61 - delegateEvent.persist();
62 - expect(delegateEvent.isPersistent()).toBe(true);
63 - });
64 -
65 -});
src/event/delegate/__tests__/DelegateWheelEvent-test.js deleted
-63
@@ -1,63 +0,0 @@
1 -/**
2 - * @emails react-core
3 - */
4 -
5 -"use strict";
6 -
7 -var DelegateWheelEvent;
8 -
9 -describe('DelegateWheelEvent', function() {
10 - var delegate;
11 -
12 - beforeEach(function() {
13 - DelegateWheelEvent = require('DelegateWheelEvent');
14 -
15 - delegate = function(nativeEvent) {
16 - return DelegateWheelEvent.getPooled({}, '', nativeEvent);
17 - };
18 - });
19 -
20 - it('should normalize properties from the Event interface', function() {
21 - var target = document.createElement('div');
22 - var delegateEvent = delegate({srcElement: target});
23 -
24 - expect(delegateEvent.target).toBe(target);
25 - expect(delegateEvent.type).toBe(undefined);
26 - });
27 -
28 - it('should normalize properties from the MouseEvent interface', function() {
29 - expect(delegate({which: 2, button: 1}).button).toBe(1);
30 - });
31 -
32 - it('should normalize properties from the WheelEvent interface', function() {
33 - var standardEvent = delegate({deltaX: 10, deltaY: -50});
34 - expect(standardEvent.deltaX).toBe(10);
35 - expect(standardEvent.deltaY).toBe(50);
36 -
37 - var webkitEvent = delegate({wheelDeltaX: -10, wheelDeltaY: 50});
38 - expect(webkitEvent.deltaX).toBe(10);
39 - expect(webkitEvent.deltaY).toBe(50);
40 - });
41 -
42 - it('should be able to `preventDefault` and `stopPropagation`', function() {
43 - var nativeEvent = {};
44 - var delegateEvent = delegate(nativeEvent);
45 -
46 - expect(delegateEvent.isDefaultPrevented()).toBe(false);
47 - delegateEvent.preventDefault();
48 - expect(delegateEvent.isDefaultPrevented()).toBe(true);
49 -
50 - expect(delegateEvent.isPropagationStopped()).toBe(false);
51 - delegateEvent.stopPropagation();
52 - expect(delegateEvent.isPropagationStopped()).toBe(true);
53 - });
54 -
55 - it('should be able to `persist`', function() {
56 - var delegateEvent = delegate({});
57 -
58 - expect(delegateEvent.isPersistent()).toBe(false);
59 - delegateEvent.persist();
60 - expect(delegateEvent.isPersistent()).toBe(true);
61 - });
62 -
63 -});
src/event/synthetic/SyntheticEvent.js renamed
+17 -16
@@ -1,5 +1,5 @@
1 /**
2 - * @providesModule DelegateEvent
2 + * @providesModule SyntheticEvent
3 * @typechecks
4 */
5
@@ -29,24 +29,25 @@ var EventInterface = {
29 };
30
31 /**
32 - * Delegate events are dispatched by top-level event delegation systems.
32 + * Synthetic events are dispatched by event plugins, typically in response to a
33 + * top-level event delegation handler.
34 *
35 * These systems should generally use pooling to reduce the frequency of garbage
36 * collection. The system should check `isPersistent` to determine whether the
37 * event should be released into the pool after being dispatched. Users that
38 * need a persisted event should invoke `persist`.
39 *
39 - * Delegate events (and subclasses) implement the DOM Level 3 Events API by
40 + * Synthetic events (and subclasses) implement the DOM Level 3 Events API by
41 * normalizing browser quirks. Subclasses do not necessarily have to implement a
42 * DOM interface; custom application-specific events can also subclass this.
43 *
43 - * @param {object} delegateConfig Configuration used by top-level delegation.
44 - * @param {string} delegateMarker Marker identifying the event target.
44 + * @param {object} dispatchConfig Configuration used to dispatch this event.
45 + * @param {string} dispatchMarker Marker identifying the event target.
46 * @param {object} nativeEvent Native browser event.
47 */
47 -function DelegateEvent(delegateConfig, delegateMarker, nativeEvent) {
48 - this.delegateConfig = delegateConfig;
49 - this.delegateMarker = delegateMarker;
48 +function SyntheticEvent(dispatchConfig, dispatchMarker, nativeEvent) {
49 + this.dispatchConfig = dispatchConfig;
50 + this.dispatchMarker = dispatchMarker;
51 this.nativeEvent = nativeEvent;
52
53 var Interface = this.constructor.Interface;
@@ -67,7 +68,7 @@ function DelegateEvent(delegateConfig, delegateMarker, nativeEvent) {
68 this.isPropagationStopped = emptyFunction.thatReturnsFalse;
69 }
70
70 -mergeInto(DelegateEvent.prototype, {
71 +mergeInto(SyntheticEvent.prototype, {
72
73 preventDefault: function() {
74 this.defaultPrevented = true;
@@ -83,7 +84,7 @@ mergeInto(DelegateEvent.prototype, {
84 },
85
86 /**
86 - * We release all dispatched `DelegateEvent`s after each event loop, adding
87 + * We release all dispatched `SyntheticEvent`s after each event loop, adding
88 * them back into the pool. This allows a way to hold onto a reference that
89 * won't be added back into the pool.
90 */
@@ -106,14 +107,14 @@ mergeInto(DelegateEvent.prototype, {
107 for (var propName in Interface) {
108 this[propName] = null;
109 }
109 - this.delegateConfig = null;
110 - this.delegateMarker = null;
110 + this.dispatchConfig = null;
111 + this.dispatchMarker = null;
112 this.nativeEvent = null;
113 }
114
115 });
116
116 -DelegateEvent.Interface = EventInterface;
117 +SyntheticEvent.Interface = EventInterface;
118
119 /**
120 * Helper to reduce boilerplate when creating subclasses.
@@ -121,7 +122,7 @@ DelegateEvent.Interface = EventInterface;
122 * @param {function} Class
123 * @param {?object} Interface
124 */
124 -DelegateEvent.augmentClass = function(Class, Interface) {
125 +SyntheticEvent.augmentClass = function(Class, Interface) {
126 var Super = this;
127
128 var prototype = Object.create(Super.prototype);
@@ -135,6 +136,6 @@ DelegateEvent.augmentClass = function(Class, Interface) {
136 PooledClass.addPoolingTo(Class, PooledClass.threeArgumentPooler);
137 };
138
138 -PooledClass.addPoolingTo(DelegateEvent, PooledClass.threeArgumentPooler);
139 +PooledClass.addPoolingTo(SyntheticEvent, PooledClass.threeArgumentPooler);
140
140 -module.exports = DelegateEvent;
141 +module.exports = SyntheticEvent;
src/event/synthetic/SyntheticFocusEvent.js new
+28
@@ -0,0 +1,28 @@
1 +/**
2 + * @providesModule SyntheticFocusEvent
3 + * @typechecks
4 + */
5 +
6 +var SyntheticUIEvent = require('SyntheticUIEvent');
7 +
8 +/**
9 + * @interface FocusEvent
10 + * @see http://www.w3.org/TR/DOM-Level-3-Events/
11 + */
12 +var FocusEventInterface = {
13 + relatedTarget: null
14 +};
15 +
16 +/**
17 + * @param {object} dispatchConfig Configuration used to dispatch this event.
18 + * @param {string} dispatchMarker Marker identifying the event target.
19 + * @param {object} nativeEvent Native browser event.
20 + * @extends {SyntheticUIEvent}
21 + */
22 +function SyntheticFocusEvent(dispatchConfig, dispatchMarker, nativeEvent) {
23 + SyntheticUIEvent.call(this, dispatchConfig, dispatchMarker, nativeEvent);
24 +}
25 +
26 +SyntheticUIEvent.augmentClass(SyntheticFocusEvent, FocusEventInterface);
27 +
28 +module.exports = SyntheticFocusEvent;
src/event/synthetic/SyntheticKeyboardEvent.js new
+40
@@ -0,0 +1,40 @@
1 +/**
2 + * @providesModule SyntheticKeyboardEvent
3 + * @typechecks
4 + */
5 +
6 +var SyntheticUIEvent = require('SyntheticUIEvent');
7 +
8 +/**
9 + * @interface KeyboardEvent
10 + * @see http://www.w3.org/TR/DOM-Level-3-Events/
11 + */
12 +var KeyboardEventInterface = {
13 + char: null,
14 + key: null,
15 + location: null,
16 + ctrlKey: null,
17 + shiftKey: null,
18 + altKey: null,
19 + metaKey: null,
20 + repeat: null,
21 + locale: null,
22 + // Legacy Interface
23 + charCode: null,
24 + keyCode: null,
25 + which: null
26 +};
27 +
28 +/**
29 + * @param {object} dispatchConfig Configuration used to dispatch this event.
30 + * @param {string} dispatchMarker Marker identifying the event target.
31 + * @param {object} nativeEvent Native browser event.
32 + * @extends {SyntheticUIEvent}
33 + */
34 +function SyntheticKeyboardEvent(dispatchConfig, dispatchMarker, nativeEvent) {
35 + SyntheticUIEvent.call(this, dispatchConfig, dispatchMarker, nativeEvent);
36 +}
37 +
38 +SyntheticUIEvent.augmentClass(SyntheticKeyboardEvent, KeyboardEventInterface);
39 +
40 +module.exports = SyntheticKeyboardEvent;
src/event/synthetic/SyntheticMouseEvent.js renamed
+9 -9
@@ -1,10 +1,10 @@
1 /**
2 - * @providesModule DelegateMouseEvent
2 + * @providesModule SyntheticMouseEvent
3 * @typechecks
4 */
5
6 var BrowserEnv = require('BrowserEnv');
7 -var DelegateUIEvent = require('DelegateUIEvent');
7 +var SyntheticUIEvent = require('SyntheticUIEvent');
8
9 /**
10 * @interface MouseEvent
@@ -55,15 +55,15 @@ var MouseEventInterface = {
55 };
56
57 /**
58 - * @param {object} reactEventType See `EventPluginHub`.
59 - * @param {string} reactTargetID ID of the target component.
58 + * @param {object} dispatchConfig Configuration used to dispatch this event.
59 + * @param {string} dispatchMarker Marker identifying the event target.
60 * @param {object} nativeEvent Native browser event.
61 - * @extends {DelegateUIEvent}
61 + * @extends {SyntheticUIEvent}
62 */
63 -function DelegateMouseEvent(reactEventType, reactTargetID, nativeEvent) {
64 - DelegateUIEvent.call(this, reactEventType, reactTargetID, nativeEvent);
63 +function SyntheticMouseEvent(dispatchConfig, dispatchMarker, nativeEvent) {
64 + SyntheticUIEvent.call(this, dispatchConfig, dispatchMarker, nativeEvent);
65 }
66
67 -DelegateUIEvent.augmentClass(DelegateMouseEvent, MouseEventInterface);
67 +SyntheticUIEvent.augmentClass(SyntheticMouseEvent, MouseEventInterface);
68
69 -module.exports = DelegateMouseEvent;
69 +module.exports = SyntheticMouseEvent;
src/event/synthetic/SyntheticMutationEvent.js new
+32
@@ -0,0 +1,32 @@
1 +/**
2 + * @providesModule SyntheticMutationEvent
3 + * @typechecks
4 + */
5 +
6 +var SyntheticEvent = require('SyntheticEvent');
7 +
8 +/**
9 + * @interface MutationEvent
10 + * @see http://www.w3.org/TR/DOM-Level-3-Events/
11 + */
12 +var MutationEventInterface = {
13 + relatedNode: null,
14 + prevValue: null,
15 + newValue: null,
16 + attrName: null,
17 + attrChange: null
18 +};
19 +
20 +/**
21 + * @param {object} dispatchConfig Configuration used to dispatch this event.
22 + * @param {string} dispatchMarker Marker identifying the event target.
23 + * @param {object} nativeEvent Native browser event.
24 + * @extends {SyntheticEvent}
25 + */
26 +function SyntheticMutationEvent(dispatchConfig, dispatchMarker, nativeEvent) {
27 + SyntheticEvent.call(this, dispatchConfig, dispatchMarker, nativeEvent);
28 +}
29 +
30 +SyntheticEvent.augmentClass(SyntheticMutationEvent, MutationEventInterface);
31 +
32 +module.exports = SyntheticMutationEvent;
src/event/synthetic/SyntheticTouchEvent.js new
+34
@@ -0,0 +1,34 @@
1 +/**
2 + * @providesModule SyntheticTouchEvent
3 + * @typechecks
4 + */
5 +
6 +var SyntheticUIEvent = require('SyntheticUIEvent');
7 +
8 +/**
9 + * @interface TouchEvent
10 + * @see http://www.w3.org/TR/DOM-Level-3-Events/
11 + */
12 +var TouchEventInterface = {
13 + touches: null,
14 + targetTouches: null,
15 + changedTouches: null,
16 + altKey: null,
17 + metaKey: null,
18 + ctrlKey: null,
19 + shiftKey: null
20 +};
21 +
22 +/**
23 + * @param {object} dispatchConfig Configuration used to dispatch this event.
24 + * @param {string} dispatchMarker Marker identifying the event target.
25 + * @param {object} nativeEvent Native browser event.
26 + * @extends {SyntheticUIEvent}
27 + */
28 +function SyntheticTouchEvent(dispatchConfig, dispatchMarker, nativeEvent) {
29 + SyntheticUIEvent.call(this, dispatchConfig, dispatchMarker, nativeEvent);
30 +}
31 +
32 +SyntheticUIEvent.augmentClass(SyntheticTouchEvent, TouchEventInterface);
33 +
34 +module.exports = SyntheticTouchEvent;
src/event/synthetic/SyntheticUIEvent.js new
+29
@@ -0,0 +1,29 @@
1 +/**
2 + * @providesModule SyntheticUIEvent
3 + * @typechecks
4 + */
5 +
6 +var SyntheticEvent = require('SyntheticEvent');
7 +
8 +/**
9 + * @interface UIEvent
10 + * @see http://www.w3.org/TR/DOM-Level-3-Events/
11 + */
12 +var UIEventInterface = {
13 + view: null,
14 + detail: null
15 +};
16 +
17 +/**
18 + * @param {object} dispatchConfig Configuration used to dispatch this event.
19 + * @param {string} dispatchMarker Marker identifying the event target.
20 + * @param {object} nativeEvent Native browser event.
21 + * @extends {SyntheticEvent}
22 + */
23 +function SyntheticUIEvent(dispatchConfig, dispatchMarker, nativeEvent) {
24 + SyntheticEvent.call(this, dispatchConfig, dispatchMarker, nativeEvent);
25 +}
26 +
27 +SyntheticEvent.augmentClass(SyntheticUIEvent, UIEventInterface);
28 +
29 +module.exports = SyntheticUIEvent;
src/event/synthetic/SyntheticWheelEvent.js renamed
+9 -9
@@ -1,9 +1,9 @@
1 /**
2 - * @providesModule DelegateWheelEvent
2 + * @providesModule SyntheticWheelEvent
3 * @typechecks
4 */
5
6 -var DelegateMouseEvent = require('DelegateMouseEvent');
6 +var SyntheticMouseEvent = require('SyntheticMouseEvent');
7
8 /**
9 * @interface WheelEvent
@@ -33,15 +33,15 @@ var WheelEventInterface = {
33 };
34
35 /**
36 - * @param {object} delegateConfig Configuration used by top-level delegation.
37 - * @param {string} delegateMarker Marker identifying the event target.
36 + * @param {object} dispatchConfig Configuration used to dispatch this event.
37 + * @param {string} dispatchMarker Marker identifying the event target.
38 * @param {object} nativeEvent Native browser event.
39 - * @extends {DelegateMouseEvent}
39 + * @extends {SyntheticMouseEvent}
40 */
41 -function DelegateWheelEvent(delegateConfig, delegateMarker, nativeEvent) {
42 - DelegateMouseEvent.call(this, delegateConfig, delegateMarker, nativeEvent);
41 +function SyntheticWheelEvent(dispatchConfig, dispatchMarker, nativeEvent) {
42 + SyntheticMouseEvent.call(this, dispatchConfig, dispatchMarker, nativeEvent);
43 }
44
45 -DelegateMouseEvent.augmentClass(DelegateWheelEvent, WheelEventInterface);
45 +SyntheticMouseEvent.augmentClass(SyntheticWheelEvent, WheelEventInterface);
46
47 -module.exports = DelegateWheelEvent;
47 +module.exports = SyntheticWheelEvent;
src/event/synthetic/__tests__/SyntheticEvent-test.js new
+67
@@ -0,0 +1,67 @@
1 +/**
2 + * @emails react-core
3 + */
4 +
5 +"use strict";
6 +
7 +var SyntheticEvent;
8 +
9 +describe('SyntheticEvent', function() {
10 + var createEvent;
11 +
12 + beforeEach(function() {
13 + SyntheticEvent = require('SyntheticEvent');
14 +
15 + createEvent = function(nativeEvent) {
16 + return SyntheticEvent.getPooled({}, '', nativeEvent);
17 + };
18 + });
19 +
20 + it('should normalize `target` from the nativeEvent', function() {
21 + var target = document.createElement('div');
22 + var syntheticEvent = createEvent({srcElement: target});
23 +
24 + expect(syntheticEvent.target).toBe(target);
25 + expect(syntheticEvent.type).toBe(undefined);
26 + });
27 +
28 + it('should be able to `preventDefault`', function() {
29 + var nativeEvent = {};
30 + var syntheticEvent = createEvent(nativeEvent);
31 +
32 + expect(syntheticEvent.isDefaultPrevented()).toBe(false);
33 + syntheticEvent.preventDefault();
34 + expect(syntheticEvent.isDefaultPrevented()).toBe(true);
35 +
36 + expect(syntheticEvent.defaultPrevented).toBe(true);
37 +
38 + expect(nativeEvent.returnValue).toBe(false);
39 + });
40 +
41 + it('should be prevented if nativeEvent is prevented', function() {
42 + expect(
43 + createEvent({defaultPrevented: true}).isDefaultPrevented()
44 + ).toBe(true);
45 + expect(createEvent({returnValue: false}).isDefaultPrevented()).toBe(true);
46 + });
47 +
48 + it('should be able to `stopPropagation`', function() {
49 + var nativeEvent = {};
50 + var syntheticEvent = createEvent(nativeEvent);
51 +
52 + expect(syntheticEvent.isPropagationStopped()).toBe(false);
53 + syntheticEvent.stopPropagation();
54 + expect(syntheticEvent.isPropagationStopped()).toBe(true);
55 +
56 + expect(nativeEvent.cancelBubble).toBe(true);
57 + });
58 +
59 + it('should be able to `persist`', function() {
60 + var syntheticEvent = createEvent({});
61 +
62 + expect(syntheticEvent.isPersistent()).toBe(false);
63 + syntheticEvent.persist();
64 + expect(syntheticEvent.isPersistent()).toBe(true);
65 + });
66 +
67 +});
src/event/synthetic/__tests__/SyntheticWheelEvent-test.js new
+63
@@ -0,0 +1,63 @@
1 +/**
2 + * @emails react-core
3 + */
4 +
5 +"use strict";
6 +
7 +var SyntheticWheelEvent;
8 +
9 +describe('SyntheticWheelEvent', function() {
10 + var createEvent;
11 +
12 + beforeEach(function() {
13 + SyntheticWheelEvent = require('SyntheticWheelEvent');
14 +
15 + createEvent = function(nativeEvent) {
16 + return SyntheticWheelEvent.getPooled({}, '', nativeEvent);
17 + };
18 + });
19 +
20 + it('should normalize properties from the Event interface', function() {
21 + var target = document.createElement('div');
22 + var syntheticEvent = createEvent({srcElement: target});
23 +
24 + expect(syntheticEvent.target).toBe(target);
25 + expect(syntheticEvent.type).toBe(undefined);
26 + });
27 +
28 + it('should normalize properties from the MouseEvent interface', function() {
29 + expect(createEvent({which: 2, button: 1}).button).toBe(1);
30 + });
31 +
32 + it('should normalize properties from the WheelEvent interface', function() {
33 + var standardEvent = createEvent({deltaX: 10, deltaY: -50});
34 + expect(standardEvent.deltaX).toBe(10);
35 + expect(standardEvent.deltaY).toBe(50);
36 +
37 + var webkitEvent = createEvent({wheelDeltaX: -10, wheelDeltaY: 50});
38 + expect(webkitEvent.deltaX).toBe(10);
39 + expect(webkitEvent.deltaY).toBe(50);
40 + });
41 +
42 + it('should be able to `preventDefault` and `stopPropagation`', function() {
43 + var nativeEvent = {};
44 + var syntheticEvent = createEvent(nativeEvent);
45 +
46 + expect(syntheticEvent.isDefaultPrevented()).toBe(false);
47 + syntheticEvent.preventDefault();
48 + expect(syntheticEvent.isDefaultPrevented()).toBe(true);
49 +
50 + expect(syntheticEvent.isPropagationStopped()).toBe(false);
51 + syntheticEvent.stopPropagation();
52 + expect(syntheticEvent.isPropagationStopped()).toBe(true);
53 + });
54 +
55 + it('should be able to `persist`', function() {
56 + var syntheticEvent = createEvent({});
57 +
58 + expect(syntheticEvent.isPersistent()).toBe(false);
59 + syntheticEvent.persist();
60 + expect(syntheticEvent.isPersistent()).toBe(true);
61 + });
62 +
63 +});