refactor: improve code formatting and consistency in processTemplateMacros utility
All checks were successful
Publish to npm / quality (push) Successful in 19s
Publish to npm / publish (push) Successful in 26s

This commit is contained in:
Astrian Zheng 2025-05-21 15:53:28 +10:00
parent 8f80a4842e
commit 828d6b0279
Signed by: Astrian
SSH Key Fingerprint: SHA256:rVnhx3DAKjujCwWE13aDl7uV6+9U1MvydLkNRXJrBiA

View File

@ -165,7 +165,7 @@ export default function processTemplateMacros(
} else if ( } else if (
options.availableFuncs.includes(handlerValue) && options.availableFuncs.includes(handlerValue) &&
typeof (context as unknown as Record<string, unknown>)[ typeof (context as unknown as Record<string, unknown>)[
handlerValue handlerValue
] === 'function' ] === 'function'
) { ) {
// Handle method reference: @click="handleClick" // Handle method reference: @click="handleClick"
@ -440,7 +440,7 @@ function processElementWithItemContext(
context: ListRenderingContext, context: ListRenderingContext,
) { ) {
// Store the item context of the element so that subsequent updates can find it // Store the item context of the element so that subsequent updates can find it
; (element as { _itemContext?: Record<string, unknown> })._itemContext = ;(element as { _itemContext?: Record<string, unknown> })._itemContext =
itemContext itemContext
// Process bindings in text nodes // Process bindings in text nodes
@ -507,7 +507,8 @@ function processElementWithItemContext(
$el: element, $el: element,
setState: context.setState, setState: context.setState,
getState: context.getState, getState: context.getState,
triggerFunc: context.triggerFunc(eventName, event) triggerFunc: (eventName: string, ...args: unknown[]) =>
context.triggerFunc(eventName, ...args),
} }
// Execute the expression // Execute the expression
@ -659,13 +660,13 @@ function setupListRendering(
// Determine the key for this item // Determine the key for this item
const key = keyAttr const key = keyAttr
? evaluateExpressionWithItemContext( ? evaluateExpressionWithItemContext(
keyAttr, keyAttr,
{ [itemVar]: item }, { [itemVar]: item },
context, context,
index, index,
itemVar, itemVar,
indexVar ? indexVar : undefined, indexVar ? indexVar : undefined,
) )
: index : index
// Check if we can reuse an existing element // Check if we can reuse an existing element