Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Component method defined in init can not be read by getMethod with specific options #137

Closed
SgLy opened this issue Mar 12, 2024 · 0 comments
Assignees
Labels

Comments

@SgLy
Copy link
Contributor

SgLy commented Mar 12, 2024

Component method defined in init will be set in _$methodMap:

comp._$methodMap[exportedKey] = exportItem
if (options.writeFieldsToNode) {
;(comp as { [key: string]: GeneralFuncType })[exportedKey] = exportItem
}

which will not be processed by methodCallerInit in adapter:
const methods = originalCaller.getComponentDefinition().behavior.getMethods()
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
proto = ret._$proto = new ComponentProto(methods, ret._$export) as any

thus, with options useMethodCallerListeners: true and writeFieldsToNode: false, getMethod can not obtain methods defined by init:
if (comp._$definition._$options.useMethodCallerListeners) {
const method = comp._$methodCaller[methodName]
return typeof method === 'function' ? method : undefined
}
return comp._$methodMap[methodName]

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants