UNPKG

@sandlada/mdc

Version:

@sandlada/mdc is an open source component library that follows the Material Design 3 design specifications.

7 lines 718 B
/** * @license * Copyright 2023 Google LLC * SPDX-License-Identifier: Apache-2.0 */ const e=Symbol(`dispatchHooks`);function t(t,n){let r=t[e];if(!r)throw Error(`'${t.type}' event needs setupDispatchHooks().`);r.addEventListener(`after`,n)}const n=new WeakMap;function r(t,...r){let i=n.get(t);i||(i=new Set,n.set(t,i));for(let n of r){if(i.has(n))continue;let r=!1;t.addEventListener(n,n=>{if(r)return;n.stopImmediatePropagation();let i=Reflect.construct(n.constructor,[n.type,n]),a=new EventTarget;i[e]=a,r=!0;let o=t.dispatchEvent(i);r=!1,o||n.preventDefault(),a.dispatchEvent(new Event(`after`))},{capture:!0}),i.add(n)}}export{t as afterDispatch,r as setupDispatchHooks}; //# sourceMappingURL=dispatch-hook.js.map