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

Function trigger

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

Source from the content-addressed store, hash-verified

472 }
473 },
474 trigger(element, event, args) {
475 if (typeof event !== 'string' || !element) {
476 return null;
477 }
478 const $ = getjQuery();
479 const typeEvent = getTypeEvent(event);
480 const inNamespace = event !== typeEvent;
481 let jQueryEvent = null;
482 let bubbles = true;
483 let nativeDispatch = true;
484 let defaultPrevented = false;
485 if (inNamespace && $) {
486 jQueryEvent = $.Event(event, args);
487 $(element).trigger(jQueryEvent);
488 bubbles = !jQueryEvent.isPropagationStopped();
489 nativeDispatch = !jQueryEvent.isImmediatePropagationStopped();
490 defaultPrevented = jQueryEvent.isDefaultPrevented();
491 }
492 const evt = hydrateObj(new Event(event, {
493 bubbles,
494 cancelable: true
495 }), args);
496 if (defaultPrevented) {
497 evt.preventDefault();
498 }
499 if (nativeDispatch) {
500 element.dispatchEvent(evt);
501 }
502 if (evt.defaultPrevented && jQueryEvent) {
503 jQueryEvent.preventDefault();
504 }
505 return evt;
506 }
507};
508function hydrateObj(obj, meta = {}) {
509 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