Created
December 12, 2023 00:42
-
-
Save PatrickJS/24493db00e89b741ef0f1e7900281492 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| if (attrValue) { | |
| const container = element.closest("[q\\:container]"); | |
| const base = new URL(getAttribute(container, "q:base"), doc.baseURI); | |
| for (const qrl of attrValue.split("\n")) { | |
| const url = new URL(qrl, base); | |
| const symbolName = url.hash.replace(/^#?([^?[|]*).*$/, "$1") || "default"; | |
| const reqTime = performance.now(); | |
| let handler = container.qFuncs?.get?.(qrl); | |
| const isSync = qrl.startsWith("#"); | |
| if (!handler) { | |
| const module = import( | |
| /* @vite-ignore */ | |
| url.href.split("#")[0]); | |
| resolveContainer(container); | |
| handler = (await module)[symbolName]; | |
| } | |
| const previousCtx = doc.__q_context__; | |
| if (element.isConnected) { | |
| try { | |
| doc.__q_context__ = [ element, ev, url ]; | |
| isSync || emitEvent("qsymbol", { | |
| symbol: symbolName, | |
| element: element, | |
| reqTime: reqTime | |
| }); | |
| await handler(ev, element); | |
| } finally { | |
| doc.__q_context__ = previousCtx; | |
| } | |
| } | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment