From fb057d3e1632af2ebde635d239e9ca7129c28cc2 Mon Sep 17 00:00:00 2001 From: chenjiajian <798095202@qq.com> Date: Thu, 14 Jan 2021 16:27:59 +0800 Subject: [PATCH] =?UTF-8?q?fix(react):=20=E4=BF=AE=E5=A4=8D=20react=20?= =?UTF-8?q?=E4=B8=8D=E8=83=BD=E5=8F=96=E6=B6=88=E4=BA=8B=E4=BB=B6=E7=9B=91?= =?UTF-8?q?=E5=90=AC=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- packages/taro-react/src/props.ts | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/packages/taro-react/src/props.ts b/packages/taro-react/src/props.ts index c9393dd38fde..e317f9a95e7f 100644 --- a/packages/taro-react/src/props.ts +++ b/packages/taro-react/src/props.ts @@ -1,6 +1,5 @@ -import { TaroElement, Style, document, FormElement } from '@tarojs/runtime' +import { TaroElement, Style, FormElement } from '@tarojs/runtime' import { isFunction, isString, isObject, isNumber, internalComponents, capitalize, toCamelCase } from '@tarojs/shared' -import { CommonEvent } from '@tarojs/components' export type Props = Record @@ -26,11 +25,11 @@ export function updateProps (dom: TaroElement, oldProps: Props, newProps: Props) } } -function eventProxy (e: CommonEvent) { - const el = document.getElementById(e.currentTarget.id) - const handlers = el!.__handlers[e.type] - handlers[0](e) -} +// function eventProxy (e: CommonEvent) { +// const el = document.getElementById(e.currentTarget.id) +// const handlers = el!.__handlers[e.type] +// handlers[0](e) +// } function setEvent (dom: TaroElement, name: string, value: unknown, oldValue?: unknown) { const isCapture = name.endsWith('Capture') @@ -47,7 +46,7 @@ function setEvent (dom: TaroElement, name: string, value: unknown, oldValue?: un if (isFunction(value)) { if (!oldValue) { - dom.addEventListener(eventName, eventProxy, isCapture) + dom.addEventListener(eventName, value, isCapture) } if (eventName === 'regionchange') { dom.__handlers.begin[0] = value @@ -56,7 +55,7 @@ function setEvent (dom: TaroElement, name: string, value: unknown, oldValue?: un dom.__handlers[eventName][0] = value } } else { - dom.removeEventListener(eventName, eventProxy) + dom.removeEventListener(eventName, oldValue as any) } }