|
9 | 9 | * This is a global (window) function that is only available when the {@link ngMock} module is
|
10 | 10 | * included.
|
11 | 11 | *
|
12 |
| - * It can be used to trigger a native browser event on an element, which is useful for testing. |
| 12 | + * It can be used to trigger a native browser event on an element, which is useful for unit testing. |
13 | 13 | *
|
14 | 14 | *
|
15 | 15 | * @param {Object} element Either a wrapped jQuery/jqLite node or a DOMElement
|
16 | 16 | * @param {string=} eventType Optional event type. If none is specified, the function tries
|
17 | 17 | * to determine the right event type for the element, e.g. `change` for
|
18 | 18 | * `input[text]`.
|
19 |
| - * @param {Object=} eventData An optional object which contains additional event data (such as x,y |
20 |
| - * coordinates, keys, etc...) that are passed into the event when |
21 |
| - * triggered. |
| 19 | + * @param {Object=} eventData An optional object which contains additional event data that is used |
| 20 | + * when creating the event: |
| 21 | + * |
| 22 | + * - `keys`: an array of possible modifier keys (ctrl, alt, shift, meta) for the event. |
| 23 | + * |
| 24 | + * - `x`: x-coordinates for [MouseEvent](https://developer.mozilla.org/docs/Web/API/MouseEvent) |
| 25 | + * and [TouchEvent](https://developer.mozilla.org/docs/Web/API/TouchEvent). |
| 26 | + * |
| 27 | + * - `y`: y-coordinates for [MouseEvent](https://developer.mozilla.org/docs/Web/API/MouseEvent) |
| 28 | + * and [TouchEvent](https://developer.mozilla.org/docs/Web/API/TouchEvent). |
| 29 | + * |
| 30 | + * - `relatedTarget`: the related target for |
| 31 | + * [MouseEvent](https://developer.mozilla.org/docs/Web/API/MouseEvent). |
| 32 | + * |
| 33 | + * - `elapsedTime`: the elapsedTime for |
| 34 | + * [TransitionEvent](https://developer.mozilla.org/docs/Web/API/TransitionEvent) |
| 35 | + * and [AnimationEvent](https://developer.mozilla.org/docs/Web/API/AnimationEvent). |
| 36 | + * |
| 37 | + * - `bubbles`: [Event.bubbles](https://developer.mozilla.org/docs/Web/API/Event/bubbles). |
| 38 | + * Not applicable to all events. |
| 39 | + * |
| 40 | + * - `cancelable`: [Event.cancelable](https://developer.mozilla.org/docs/Web/API/Event/cancelable). |
| 41 | + * Not applicable to all events. |
| 42 | +
|
22 | 43 | */
|
23 | 44 | window.browserTrigger = function browserTrigger(element, eventType, eventData) {
|
24 | 45 | if (element && !element.nodeName) element = element[0];
|
|
114 | 135 |
|
115 | 136 | if (!evnt) return;
|
116 | 137 |
|
117 |
| - var originalPreventDefault = evnt.preventDefault, |
118 |
| - appWindow = element.ownerDocument.defaultView, |
119 |
| - fakeProcessDefault = true, |
120 |
| - finalProcessDefault, |
121 |
| - angular = appWindow.angular || {}; |
122 |
| - |
123 |
| - // igor: temporary fix for https://bugzilla.mozilla.org/show_bug.cgi?id=684208 |
124 |
| - angular['ff-684208-preventDefault'] = false; |
125 |
| - evnt.preventDefault = function() { |
126 |
| - fakeProcessDefault = false; |
127 |
| - return originalPreventDefault.apply(evnt, arguments); |
128 |
| - }; |
129 |
| - |
130 | 138 | if (!eventData.bubbles || supportsEventBubblingInDetachedTree() || isAttachedToDocument(element)) {
|
131 |
| - element.dispatchEvent(evnt); |
| 139 | + return element.dispatchEvent(evnt); |
132 | 140 | } else {
|
133 | 141 | triggerForPath(element, evnt);
|
134 | 142 | }
|
135 |
| - |
136 |
| - finalProcessDefault = !(angular['ff-684208-preventDefault'] || !fakeProcessDefault); |
137 |
| - |
138 |
| - delete angular['ff-684208-preventDefault']; |
139 |
| - |
140 |
| - return finalProcessDefault; |
141 | 143 | };
|
142 | 144 |
|
143 | 145 | function supportsTouchEvents() {
|
|
0 commit comments