提交 2f7b3e55 编写于 作者: fxy060608's avatar fxy060608

fix(h5): Pass $ownerInstance parameter to the event of html tag (#3436)

上级 10da8165
......@@ -23,7 +23,14 @@ export function $nne(
// App 平台时不返回原始事件对象 https://github.com/dcloudio/uni-app/issues/3240
if (__PLATFORM__ === 'h5') {
if (isHTMLTarget) {
return [evt]
return (
wrapperH5WxsEvent(
evt,
eventValue,
instance as ComponentInternalInstance,
false // 原生标签事件可能被cache,参数长度不准确,故默认不校验
) || [evt]
)
}
}
......
......@@ -243,9 +243,13 @@ export function getComponentDescriptor(
function resolveOwnerComponentPublicInstance(
eventValue: Function,
instance: ComponentInternalInstance | null
instance: ComponentInternalInstance | null,
checkArgsLength = true
) {
if (!instance || eventValue.length < 2) {
if (!instance) {
return false
}
if (checkArgsLength && eventValue.length < 2) {
return false
}
const ownerVm = resolveOwnerVm(instance)
......@@ -262,7 +266,8 @@ function resolveOwnerComponentPublicInstance(
export function wrapperH5WxsEvent(
event: Record<string, any>,
eventValue?: Function,
instance?: ComponentInternalInstance | null
instance?: ComponentInternalInstance | null,
checkArgsLength = true
) {
if (eventValue) {
Object.defineProperty(event, 'instance', {
......@@ -270,7 +275,11 @@ export function wrapperH5WxsEvent(
return getComponentDescriptor(instance!.proxy!, false)
},
})
const ownerVm = resolveOwnerComponentPublicInstance(eventValue, instance!)
const ownerVm = resolveOwnerComponentPublicInstance(
eventValue,
instance!,
checkArgsLength
)
if (ownerVm) {
return [event, getComponentDescriptor(ownerVm, false)]
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册