|
2 | 2 |
|
3 | 3 | (function() {
|
4 | 4 | /**
|
5 |
| - * Triggers a browser event. Attempts to choose the right event if one is |
6 |
| - * not specified. |
| 5 | + * @ngdoc function |
| 6 | + * @name browserTrigger |
| 7 | + * @description |
| 8 | + * |
| 9 | + * This is a global (window) function that is only available when the {@link ngMock} module is |
| 10 | + * included. |
| 11 | + * |
| 12 | + * It can be used to trigger a native browser event on an element, which is useful for unit testing. |
| 13 | + * |
7 | 14 | *
|
8 | 15 | * @param {Object} element Either a wrapped jQuery/jqLite node or a DOMElement
|
9 |
| - * @param {string} eventType Optional event type |
10 |
| - * @param {Object=} eventData An optional object which contains additional event data (such as x,y |
11 |
| - * coordinates, keys, etc...) that are passed into the event when triggered |
| 16 | + * @param {string=} eventType Optional event type. If none is specified, the function tries |
| 17 | + * to determine the right event type for the element, e.g. `change` for |
| 18 | + * `input[text]`. |
| 19 | + * @param {Object=} eventData An optional object which contains additional event data that is used |
| 20 | + * when creating the event: |
| 21 | + * |
| 22 | + * - `bubbles`: [Event.bubbles](https://developer.mozilla.org/docs/Web/API/Event/bubbles). |
| 23 | + * Not applicable to all events. |
| 24 | + * |
| 25 | + * - `cancelable`: [Event.cancelable](https://developer.mozilla.org/docs/Web/API/Event/cancelable). |
| 26 | + * Not applicable to all events. |
| 27 | + * |
| 28 | + * - `charcode`: [charCode](https://developer.mozilla.org/docs/Web/API/KeyboardEvent/charcode) |
| 29 | + * for keyboard events (keydown, keypress, and keyup). |
| 30 | + * |
| 31 | + * - `elapsedTime`: the elapsedTime for |
| 32 | + * [TransitionEvent](https://developer.mozilla.org/docs/Web/API/TransitionEvent) |
| 33 | + * and [AnimationEvent](https://developer.mozilla.org/docs/Web/API/AnimationEvent). |
| 34 | + * |
| 35 | + * - `keycode`: [keyCode](https://developer.mozilla.org/docs/Web/API/KeyboardEvent/keycode) |
| 36 | + * for keyboard events (keydown, keypress, and keyup). |
| 37 | + * |
| 38 | + * - `keys`: an array of possible modifier keys (ctrl, alt, shift, meta) for |
| 39 | + * [MouseEvent](https://developer.mozilla.org/docs/Web/API/MouseEvent) and |
| 40 | + * keyboard events (keydown, keypress, and keyup). |
| 41 | + * |
| 42 | + * - `relatedTarget`: the |
| 43 | + * [relatedTarget](https://developer.mozilla.org/docs/Web/API/MouseEvent/relatedTarget) |
| 44 | + * for [MouseEvent](https://developer.mozilla.org/docs/Web/API/MouseEvent). |
| 45 | + * |
| 46 | + * - `which`: [which](https://developer.mozilla.org/docs/Web/API/KeyboardEvent/which) |
| 47 | + * for keyboard events (keydown, keypress, and keyup). |
| 48 | + * |
| 49 | + * - `x`: x-coordinates for [MouseEvent](https://developer.mozilla.org/docs/Web/API/MouseEvent) |
| 50 | + * and [TouchEvent](https://developer.mozilla.org/docs/Web/API/TouchEvent). |
| 51 | + * |
| 52 | + * - `y`: y-coordinates for [MouseEvent](https://developer.mozilla.org/docs/Web/API/MouseEvent) |
| 53 | + * and [TouchEvent](https://developer.mozilla.org/docs/Web/API/TouchEvent). |
| 54 | + * |
12 | 55 | */
|
13 | 56 | window.browserTrigger = function browserTrigger(element, eventType, eventData) {
|
14 | 57 | if (element && !element.nodeName) element = element[0];
|
|
0 commit comments