MCPcopy
hub / github.com/angular-ui/ui-router / triggerClick

Function triggerClick

test/stateDirectivesSpec.ts:58–89  ·  view source on GitHub ↗
(el, options?)

Source from the content-addressed store, hash-verified

56 }));
57
58 function triggerClick(el, options?) {
59 options = angular.extend(
60 {
61 metaKey: false,
62 ctrlKey: false,
63 shiftKey: false,
64 altKey: false,
65 button: 0,
66 },
67 options || {}
68 );
69
70 const e = document.createEvent('MouseEvents');
71 e.initMouseEvent(
72 'click', // typeArg of type DOMString, Specifies the event type.
73 true, // canBubbleArg of type boolean, Specifies whether or not the event can bubble.
74 true, // cancelableArg of type boolean, Specifies whether or not the event's default action can be prevented.
75 undefined, // viewArg of type views::AbstractView, Specifies the Event's AbstractView.
76 0, // detailArg of type long, Specifies the Event's mouse click count.
77 0, // screenXArg of type long, Specifies the Event's screen x coordinate
78 0, // screenYArg of type long, Specifies the Event's screen y coordinate
79 0, // clientXArg of type long, Specifies the Event's client x coordinate
80 0, // clientYArg of type long, Specifies the Event's client y coordinate
81 options.ctrlKey, // ctrlKeyArg of type boolean, Specifies whether or not control key was depressed during the Event.
82 options.altKey, // altKeyArg of type boolean, Specifies whether or not alt key was depressed during the Event.
83 options.shiftKey, // shiftKeyArg of type boolean, Specifies whether or not shift key was depressed during the Event.
84 options.metaKey, // metaKeyArg of type boolean, Specifies whether or not meta key was depressed during the Event.
85 options.button, // buttonArg of type unsigned short, Specifies the Event's mouse button.
86 null // relatedTargetArg of type EventTarget
87 );
88 el[0].dispatchEvent(e);
89 }
90
91 function triggerHTMLEvent(name) {
92 const event = document.createEvent('HTMLEvents');

Callers 1

Calls

no outgoing calls

Tested by

no test coverage detected