chore: modify the function calling
All checks were successful
Quality Check & Publish / quality (push) Successful in 23s
Quality Check & Publish / quality-failed-webhook (push) Has been skipped
Quality Check & Publish / publish (push) Successful in 26s
Quality Check & Publish / publish-failed-webhook (push) Has been skipped

This commit is contained in:
Astrian Zheng 2025-05-21 20:57:24 +10:00
parent 0131cab6ac
commit 2c04be8607
Signed by: Astrian
SSH Key Fingerprint: SHA256:rVnhx3DAKjujCwWE13aDl7uV6+9U1MvydLkNRXJrBiA
3 changed files with 5 additions and 21 deletions

View File

@ -155,7 +155,7 @@ export default (options: ComponentOptions) => {
this._extractStatePathsFromExpression.bind(this),
states: this._states,
triggerFunc: this.triggerFunc.bind(this),
setupArrowFunctionHandler: utils.setupArrowFunctionHandler.bind(this),
// setupArrowFunctionHandler: utils.setupArrowFunctionHandler.bind(this),
})
}

View File

@ -1,5 +1,5 @@
import parseTemplate from './parseTemplate'
import processTemplateMacros from './processTemplateMarco'
import processTemplateMacros from './processTemplateMarcos'
import setupArrowFunctionHandler from './setupArrowFunctionHandler'
import triggerDomUpdates from './triggerDomUpdates'

View File

@ -1,3 +1,5 @@
import setupArrowFunctionHandler from './setupArrowFunctionHandler'
export default function processTemplateMacros(
element: Element,
context: CustomElement,
@ -9,24 +11,6 @@ export default function processTemplateMacros(
expr: string,
attrValue: string,
) => void
setupArrowFunctionHandler: (
element: Element,
eventName: string,
handlerValue: string,
ops: {
createHandlerContext: (
event: Event,
element: Element,
) => {
states: Record<string, unknown>
stateToElementsMap: Record<string, Set<HTMLElement>>
statesListeners: Record<string, (value: unknown) => void>
setState: (keyPath: string, value: unknown) => void
getState: (keyPath: string) => unknown
triggerFunc: (eventName: string, ...args: unknown[]) => void
}
},
) => void
setupFunctionCallHandler: (
element: Element,
eventName: string,
@ -162,7 +146,7 @@ export default function processTemplateMacros(
// Handle different types of event handlers
if (handlerValue.includes('=>')) {
// Handle arrow function: @click="e => setState('count', count + 1)"
options.setupArrowFunctionHandler(
setupArrowFunctionHandler(
currentElementNode,
eventName,
handlerValue,