Skip to content

Commit

Permalink
fix(plugin-compiler-alipay): 支付宝转微信时 input 事件失效
Browse files Browse the repository at this point in the history
  • Loading branch information
hwaphon committed May 21, 2024
1 parent 11bc996 commit 971810c
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions packages/plugin-compiler-alipay/src/templateEvents.ts
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,9 @@ const tagReplacePropName = {
}
}

// 处理特殊场景时,将 input 转换成此别名
const INPUT_ALIAS_NAME = 'mor-input'

/**
* 判断小程序组件属性是否是事件(是否以on开头)
*/
Expand Down Expand Up @@ -193,6 +196,9 @@ export function getEventName(attr: string): string {
*/
export function isNativeEvent(eventName: string, tag: string): boolean {
const eventLowerName = eventName.toLowerCase()
// 转 wechat 时,为了使 input 可以内嵌元素,实现了一个插件在 preprocess 阶段将 input 转换成了 mor-input
// 所以为了对事件进行兼容,当 tag 为input元素时,将标签名转为原标签名
if (tag === INPUT_ALIAS_NAME) tag = 'input' // 纠正标签名
if (commonNativeEvent.includes(eventLowerName)) {
return true
}
Expand Down

0 comments on commit 971810c

Please sign in to comment.