MCPcopy Create free account
hub / github.com/aspnet/AzureSignalR-samples / trigger

Function trigger

aspnet-samples/AspNetForm/Scripts/bootstrap.js:497–529  ·  view source on GitHub ↗
(element, event, args)

Source from the content-addressed store, hash-verified

495 }
496 },
497 trigger(element, event, args) {
498 if (typeof event !== 'string' || !element) {
499 return null;
500 }
501 const $ = getjQuery();
502 const typeEvent = getTypeEvent(event);
503 const inNamespace = event !== typeEvent;
504 let jQueryEvent = null;
505 let bubbles = true;
506 let nativeDispatch = true;
507 let defaultPrevented = false;
508 if (inNamespace && $) {
509 jQueryEvent = $.Event(event, args);
510 $(element).trigger(jQueryEvent);
511 bubbles = !jQueryEvent.isPropagationStopped();
512 nativeDispatch = !jQueryEvent.isImmediatePropagationStopped();
513 defaultPrevented = jQueryEvent.isDefaultPrevented();
514 }
515 const evt = hydrateObj(new Event(event, {
516 bubbles,
517 cancelable: true
518 }), args);
519 if (defaultPrevented) {
520 evt.preventDefault();
521 }
522 if (nativeDispatch) {
523 element.dispatchEvent(evt);
524 }
525 if (evt.defaultPrevented && jQueryEvent) {
526 jQueryEvent.preventDefault();
527 }
528 return evt;
529 }
530 };
531 function hydrateObj(obj, meta = {}) {
532 for (const [key, value] of Object.entries(meta)) {

Callers

nothing calls this directly

Calls 4

getjQueryFunction · 0.70
getTypeEventFunction · 0.70
$Function · 0.70
hydrateObjFunction · 0.70

Tested by

no test coverage detected