From 903fa526e9cf7f3672c7e17d24e23389179d1ea2 Mon Sep 17 00:00:00 2001 From: lareinayanyu Date: Tue, 14 Jan 2025 17:21:02 +0800 Subject: [PATCH 1/6] =?UTF-8?q?feat:=20=E6=8B=86=E5=88=86=E5=B0=8F?= =?UTF-8?q?=E7=A8=8B=E5=BA=8F=E4=BA=8B=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../platform/builtInMixins/proxyEventMixin.js | 62 ++++++++++++++++++- .../lib/template-compiler/compiler.js | 60 +++++++++++++++--- 2 files changed, 111 insertions(+), 11 deletions(-) diff --git a/packages/core/src/platform/builtInMixins/proxyEventMixin.js b/packages/core/src/platform/builtInMixins/proxyEventMixin.js index 3b1003bb56..381a9508cd 100644 --- a/packages/core/src/platform/builtInMixins/proxyEventMixin.js +++ b/packages/core/src/platform/builtInMixins/proxyEventMixin.js @@ -38,7 +38,67 @@ export default function proxyEventMixin () { error(`[${type}] event object must have [currentTarget/target] property!`, location) return } - const eventConfigs = target.dataset.eventconfigs || {} + const eventConfigs = target.dataset.eventconfigs?.bubble || {} + const curEventConfig = eventConfigs[type] || eventConfigs[fallbackType] || [] + // 如果有 mpxuid 说明是运行时组件,那么需要设置对应的上下文 + const rootRuntimeContext = contextMap.get(target.dataset.mpxuid) + const context = rootRuntimeContext || this + let returnedValue + curEventConfig.forEach((item) => { + const callbackName = item[0] + if (emitMode) { + // thanos 平台特殊事件标识处理 + $event = $event.detail.data + } + if (callbackName) { + const params = item.length > 1 + ? item.slice(1).map(item => { + if (item === '__mpx_event__') { + return $event + } else { + return item + } + }) + : [$event] + if (typeof context[callbackName] === 'function') { + returnedValue = context[callbackName].apply(context, params) + } else { + logCallbackNotFound(context, callbackName) + } + } + }) + return returnedValue + }, + __captureInvoke ($event) { + if (typeof Mpx.config.proxyEventHandler === 'function') { + try { + Mpx.config.proxyEventHandler($event) + } catch (e) { + } + } + const location = this.__mpxProxy.options.mpxFileResource + const type = $event.type + // thanos 平台特殊事件标识 + const emitMode = $event.detail && $event.detail.mpxEmit + if (!type) { + error('Event object must have [type] property!', location) + return + } + let fallbackType = '' + if (type === 'begin' || type === 'end') { + // 地图的 regionchange 事件会派发 e.type 为 begin 和 end 的事件 + fallbackType = __mpx_mode__ === 'ali' ? 'regionChange' : 'regionchange' + } else if (/-([a-z])/.test(type)) { + fallbackType = dash2hump(type) + } else if (__mpx_mode__ === 'ali') { + fallbackType = type.replace(/^./, i => i.toLowerCase()) + } + const target = $event.currentTarget || $event.target + if (!target) { + error(`[${type}] event object must have [currentTarget/target] property!`, location) + return + } + const eventConfigs = target.dataset.eventconfigs?.capture || {} const curEventConfig = eventConfigs[type] || eventConfigs[fallbackType] || [] // 如果有 mpxuid 说明是运行时组件,那么需要设置对应的上下文 const rootRuntimeContext = contextMap.get(target.dataset.mpxuid) diff --git a/packages/webpack-plugin/lib/template-compiler/compiler.js b/packages/webpack-plugin/lib/template-compiler/compiler.js index 2781eee4be..9b1ff24b98 100644 --- a/packages/webpack-plugin/lib/template-compiler/compiler.js +++ b/packages/webpack-plugin/lib/template-compiler/compiler.js @@ -1324,12 +1324,15 @@ function processEvent (el, options) { const extraStr = runtimeCompile && prefix === 'catch' ? `, "__mpx_${prefix}"` : '' const parsedFunc = parseFuncStr(value, extraStr) if (parsedFunc) { + const isCapture = modifiers.indexOf('capture') > -1 if (!eventConfigMap[type]) { eventConfigMap[type] = { - configs: [] + configs: [], + captureConfigs: [] } } - eventConfigMap[type].configs.push(Object.assign({ name }, parsedFunc)) + const targetConfigs = isCapture ? eventConfigMap[type].captureConfigs : eventConfigMap[type].configs + targetConfigs.push(Object.assign({ name }, parsedFunc)) if (modifiers.indexOf('proxy') > -1 || options.forceProxyEvent) { eventConfigMap[type].proxy = true } @@ -1371,25 +1374,32 @@ function processEvent (el, options) { } for (const type in eventConfigMap) { - let needBind = false - const { configs, proxy } = eventConfigMap[type] + let needBubblingBind = false + let needCaptureBind = false + const { configs, captureConfigs, proxy } = eventConfigMap[type] delete eventConfigMap[type] if (proxy) { - needBind = true + needBubblingBind = true + needCaptureBind = true } else if (configs.length > 1) { - needBind = true + needBubblingBind = true + } else if (captureConfigs.length > 1) { + needCaptureBind = true } else if (configs.length === 1) { - needBind = !!configs[0].hasArgs + needBubblingBind = !!configs[0].hasArgs + } else if (captureConfigs.length === 1) { + needCaptureBind = !!captureConfigs[0].hasArgs } const escapedType = dash2hump(type) // 排除特殊情况 if (!isValidIdentifierStr(escapedType)) { warn$1(`EventName ${type} which need be framework proxy processed must be a valid identifier!`) - needBind = false + needBubblingBind = false + needCaptureBind = false } - if (needBind) { + if (needBubblingBind) { let resultName configs.forEach(({ name }) => { if (name) { @@ -1412,7 +1422,37 @@ function processEvent (el, options) { value: '__invoke' } ]) - eventConfigMap[escapedType] = configs.map((item) => { + eventConfigMap.bubble = {} + eventConfigMap.bubble[escapedType] = configs.map((item) => { + return item.expStr + }) + } + + if (needCaptureBind) { + let resultName + captureConfigs.forEach(({ name }) => { + if (name) { + // 清空原始事件绑定 + let has + do { + has = getAndRemoveAttr(el, name).has + } while (has) + + if (!resultName) { + // 清除修饰符 + resultName = name.replace(/\..*/, '') + } + } + }) + + addAttrs(el, [ + { + name: resultName || config[mode].event.getEvent(type), + value: '__captureInvoke' + } + ]) + eventConfigMap.capture = {} + eventConfigMap.capture[escapedType] = captureConfigs.map((item) => { return item.expStr }) } From 8fa525acaad4a5e8c4706447199b2550013878cf Mon Sep 17 00:00:00 2001 From: lareinayanyu Date: Tue, 14 Jan 2025 18:36:46 +0800 Subject: [PATCH 2/6] fix: error --- packages/webpack-plugin/lib/template-compiler/compiler.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/webpack-plugin/lib/template-compiler/compiler.js b/packages/webpack-plugin/lib/template-compiler/compiler.js index 9b1ff24b98..b3e1bba938 100644 --- a/packages/webpack-plugin/lib/template-compiler/compiler.js +++ b/packages/webpack-plugin/lib/template-compiler/compiler.js @@ -1324,7 +1324,7 @@ function processEvent (el, options) { const extraStr = runtimeCompile && prefix === 'catch' ? `, "__mpx_${prefix}"` : '' const parsedFunc = parseFuncStr(value, extraStr) if (parsedFunc) { - const isCapture = modifiers.indexOf('capture') > -1 + const isCapture = prefix.indexOf('capture') > -1 if (!eventConfigMap[type]) { eventConfigMap[type] = { configs: [], @@ -1376,7 +1376,7 @@ function processEvent (el, options) { for (const type in eventConfigMap) { let needBubblingBind = false let needCaptureBind = false - const { configs, captureConfigs, proxy } = eventConfigMap[type] + const { configs = [], captureConfigs = [], proxy } = eventConfigMap[type] delete eventConfigMap[type] if (proxy) { needBubblingBind = true From a66c8681e5048fbab64129de17850abc39103e33 Mon Sep 17 00:00:00 2001 From: lareinayanyu Date: Tue, 14 Jan 2025 19:20:38 +0800 Subject: [PATCH 3/6] fix: ali --- .../lib/platform/template/wx/index.js | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/packages/webpack-plugin/lib/platform/template/wx/index.js b/packages/webpack-plugin/lib/platform/template/wx/index.js index 1da86356b1..82d5db8c4c 100644 --- a/packages/webpack-plugin/lib/platform/template/wx/index.js +++ b/packages/webpack-plugin/lib/platform/template/wx/index.js @@ -301,9 +301,16 @@ module.exports = function getSpec ({ warn, error }) { const modifierStr = match[3] || '' const rPrefix = runRules(spec.event.prefix, prefix, { mode: 'ali' }) const rEventName = runRules(eventRules, eventName, { mode: 'ali' }) - return { - name: dash2hump(rPrefix + '-' + rEventName) + modifierStr, - value + if (rPrefix === 'capture-on' || rPrefix === 'capture-catch') { + return { + name: rPrefix + rEventName.replace(/^[a-z]/, l => l.toUpperCase()) + modifierStr, + value + } + } else { + return { + name: dash2hump(rPrefix + '-' + rEventName) + modifierStr, + value + } } }, swan ({ name, value }, { eventRules }) { @@ -444,7 +451,9 @@ module.exports = function getSpec ({ warn, error }) { ali (prefix) { const prefixMap = { bind: 'on', - catch: 'catch' + catch: 'catch', + 'capture-catch': 'capture-catch', + 'capture-bind': 'capture-on' } if (!prefixMap[prefix]) { error(`Ali environment does not support [${prefix}] event handling!`) From c187d4d72399a304e1ff4ddc688da48b9c7dee8e Mon Sep 17 00:00:00 2001 From: lareinayanyu Date: Wed, 15 Jan 2025 11:52:08 +0800 Subject: [PATCH 4/6] =?UTF-8?q?chore:=20=E4=BF=AE=E6=94=B9=5F=5FcaptureInv?= =?UTF-8?q?oke?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../platform/builtInMixins/proxyEventMixin.js | 208 ++++++++---------- .../lib/template-compiler/compiler.js | 2 +- 2 files changed, 90 insertions(+), 120 deletions(-) diff --git a/packages/core/src/platform/builtInMixins/proxyEventMixin.js b/packages/core/src/platform/builtInMixins/proxyEventMixin.js index 381a9508cd..2057a6e1d1 100644 --- a/packages/core/src/platform/builtInMixins/proxyEventMixin.js +++ b/packages/core/src/platform/builtInMixins/proxyEventMixin.js @@ -4,145 +4,115 @@ import contextMap from '../../dynamic/vnode/context' function logCallbackNotFound (context, callbackName) { const location = context.__mpxProxy && context.__mpxProxy.options.mpxFileResource - error(`Instance property [${callbackName}] is not function, please check.`, location) + error( + `Instance property [${callbackName}] is not function, please check.`, + location + ) } -export default function proxyEventMixin () { - const methods = { - __invoke ($event) { - if (typeof Mpx.config.proxyEventHandler === 'function') { - try { - Mpx.config.proxyEventHandler($event) - } catch (e) { - } - } - const location = this.__mpxProxy.options.mpxFileResource - const type = $event.type - // thanos 平台特殊事件标识 - const emitMode = $event.detail && $event.detail.mpxEmit - if (!type) { - error('Event object must have [type] property!', location) - return - } - let fallbackType = '' - if (type === 'begin' || type === 'end') { - // 地图的 regionchange 事件会派发 e.type 为 begin 和 end 的事件 - fallbackType = __mpx_mode__ === 'ali' ? 'regionChange' : 'regionchange' - } else if (/-([a-z])/.test(type)) { - fallbackType = dash2hump(type) - } else if (__mpx_mode__ === 'ali') { - fallbackType = type.replace(/^./, i => i.toLowerCase()) - } - const target = $event.currentTarget || $event.target - if (!target) { - error(`[${type}] event object must have [currentTarget/target] property!`, location) - return - } - const eventConfigs = target.dataset.eventconfigs?.bubble || {} - const curEventConfig = eventConfigs[type] || eventConfigs[fallbackType] || [] - // 如果有 mpxuid 说明是运行时组件,那么需要设置对应的上下文 - const rootRuntimeContext = contextMap.get(target.dataset.mpxuid) - const context = rootRuntimeContext || this - let returnedValue - curEventConfig.forEach((item) => { - const callbackName = item[0] - if (emitMode) { - // thanos 平台特殊事件标识处理 - $event = $event.detail.data - } - if (callbackName) { - const params = item.length > 1 - ? item.slice(1).map(item => { +function handleEvent (context, $event, isCapture) { + if (typeof Mpx.config.proxyEventHandler === 'function') { + try { + Mpx.config.proxyEventHandler($event) + } catch (e) {} + } + const location = context.__mpxProxy.options.mpxFileResource + const type = $event.type + // thanos 平台特殊事件标识 + const emitMode = $event.detail && $event.detail.mpxEmit + if (!type) { + error('Event object must have [type] property!', location) + return + } + let fallbackType = '' + if (type === 'begin' || type === 'end') { + // 地图的 regionchange 事件会派发 e.type 为 begin 和 end 的事件 + fallbackType = __mpx_mode__ === 'ali' ? 'regionChange' : 'regionchange' + } else if (/-([a-z])/.test(type)) { + fallbackType = dash2hump(type) + } else if (__mpx_mode__ === 'ali') { + fallbackType = type.replace(/^./, (i) => i.toLowerCase()) + } + const target = $event.currentTarget || $event.target + if (!target) { + error( + `[${type}] event object must have [currentTarget/target] property!`, + location + ) + return + } + const mode = isCapture ? 'capture' : 'bubble' + const eventConfigs = target.dataset.eventconfigs?.[mode] || {} + const curEventConfig = eventConfigs[type] || eventConfigs[fallbackType] || [] + // 如果有 mpxuid 说明是运行时组件,那么需要设置对应的上下文 + const rootRuntimeContext = contextMap.get(target.dataset.mpxuid) + const runtimeContext = rootRuntimeContext || context + let returnedValue + curEventConfig.forEach((item) => { + const callbackName = item[0] + if (emitMode) { + // thanos 平台特殊事件标识处理 + $event = $event.detail.data + } + if (callbackName) { + const params = + item.length > 1 + ? item.slice(1).map((item) => { if (item === '__mpx_event__') { return $event } else { return item } }) - : [$event] - if (typeof context[callbackName] === 'function') { - returnedValue = context[callbackName].apply(context, params) - } else { - logCallbackNotFound(context, callbackName) - } - } - }) - return returnedValue + : [$event] + if (typeof runtimeContext[callbackName] === 'function') { + returnedValue = runtimeContext[callbackName].apply( + runtimeContext, + params + ) + } else { + logCallbackNotFound(runtimeContext, callbackName) + } + } + }) + return returnedValue +} + +export default function proxyEventMixin () { + const methods = { + __invoke ($event) { + return handleEvent(this, $event, false) }, __captureInvoke ($event) { - if (typeof Mpx.config.proxyEventHandler === 'function') { - try { - Mpx.config.proxyEventHandler($event) - } catch (e) { - } - } - const location = this.__mpxProxy.options.mpxFileResource - const type = $event.type - // thanos 平台特殊事件标识 - const emitMode = $event.detail && $event.detail.mpxEmit - if (!type) { - error('Event object must have [type] property!', location) - return - } - let fallbackType = '' - if (type === 'begin' || type === 'end') { - // 地图的 regionchange 事件会派发 e.type 为 begin 和 end 的事件 - fallbackType = __mpx_mode__ === 'ali' ? 'regionChange' : 'regionchange' - } else if (/-([a-z])/.test(type)) { - fallbackType = dash2hump(type) - } else if (__mpx_mode__ === 'ali') { - fallbackType = type.replace(/^./, i => i.toLowerCase()) - } - const target = $event.currentTarget || $event.target - if (!target) { - error(`[${type}] event object must have [currentTarget/target] property!`, location) - return - } - const eventConfigs = target.dataset.eventconfigs?.capture || {} - const curEventConfig = eventConfigs[type] || eventConfigs[fallbackType] || [] - // 如果有 mpxuid 说明是运行时组件,那么需要设置对应的上下文 - const rootRuntimeContext = contextMap.get(target.dataset.mpxuid) - const context = rootRuntimeContext || this - let returnedValue - curEventConfig.forEach((item) => { - const callbackName = item[0] - if (emitMode) { - // thanos 平台特殊事件标识处理 - $event = $event.detail.data - } - if (callbackName) { - const params = item.length > 1 - ? item.slice(1).map(item => { - if (item === '__mpx_event__') { - return $event - } else { - return item - } - }) - : [$event] - if (typeof context[callbackName] === 'function') { - returnedValue = context[callbackName].apply(context, params) - } else { - logCallbackNotFound(context, callbackName) - } - } - }) - return returnedValue + return handleEvent(this, $event, true) }, __model (expr, $event, valuePath = ['value'], filterMethod) { const innerFilter = { - trim: val => typeof val === 'string' && val.trim() + trim: (val) => typeof val === 'string' && val.trim() } - const originValue = valuePath.reduce((acc, cur) => acc[cur], $event.detail) - const value = filterMethod ? (innerFilter[filterMethod] ? innerFilter[filterMethod](originValue) : typeof this[filterMethod] === 'function' ? this[filterMethod](originValue) : originValue) : originValue + const originValue = valuePath.reduce( + (acc, cur) => acc[cur], + $event.detail + ) + const value = filterMethod + ? innerFilter[filterMethod] + ? innerFilter[filterMethod](originValue) + : typeof this[filterMethod] === 'function' + ? this[filterMethod](originValue) + : originValue + : originValue setByPath(this, expr, value) } } if (__mpx_mode__ === 'ali') { Object.assign(methods, { triggerEvent (eventName, eventDetail) { - const handlerName = eventName.replace(/^./, matched => matched.toUpperCase()).replace(/-([a-z])/g, (match, p1) => p1.toUpperCase()) - const handler = this.props && (this.props['on' + handlerName] || this.props['catch' + handlerName]) + const handlerName = eventName + .replace(/^./, (matched) => matched.toUpperCase()) + .replace(/-([a-z])/g, (match, p1) => p1.toUpperCase()) + const handler = + this.props && + (this.props['on' + handlerName] || this.props['catch' + handlerName]) if (handler && typeof handler === 'function') { const dataset = collectDataset(this.props) const id = this.props.id || '' diff --git a/packages/webpack-plugin/lib/template-compiler/compiler.js b/packages/webpack-plugin/lib/template-compiler/compiler.js index b3e1bba938..71a29f4948 100644 --- a/packages/webpack-plugin/lib/template-compiler/compiler.js +++ b/packages/webpack-plugin/lib/template-compiler/compiler.js @@ -1324,7 +1324,7 @@ function processEvent (el, options) { const extraStr = runtimeCompile && prefix === 'catch' ? `, "__mpx_${prefix}"` : '' const parsedFunc = parseFuncStr(value, extraStr) if (parsedFunc) { - const isCapture = prefix.indexOf('capture') > -1 + const isCapture = /^capture/.test(prefix) if (!eventConfigMap[type]) { eventConfigMap[type] = { configs: [], From 55bf00eee96b3a288f1f1aeaec34224c16caba07 Mon Sep 17 00:00:00 2001 From: lareinayanyu Date: Wed, 15 Jan 2025 14:43:14 +0800 Subject: [PATCH 5/6] =?UTF-8?q?chore:=20=E4=BF=AE=E6=94=B9event=20binding?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../lib/template-compiler/compiler.js | 84 ++++++++----------- 1 file changed, 37 insertions(+), 47 deletions(-) diff --git a/packages/webpack-plugin/lib/template-compiler/compiler.js b/packages/webpack-plugin/lib/template-compiler/compiler.js index 71a29f4948..5a736ebacd 100644 --- a/packages/webpack-plugin/lib/template-compiler/compiler.js +++ b/packages/webpack-plugin/lib/template-compiler/compiler.js @@ -1311,6 +1311,32 @@ function processEventReact (el) { // } } +function isNeedBind (configs, isProxy) { + if (isProxy) return true + if (configs.length > 1) return true + if (configs.length === 1) return configs[0].hasArgs + return false +} + +function processEventBinding (el, configs) { + let resultName + configs.forEach(({ name }) => { + if (name) { + // 清空原始事件绑定 + let has + do { + has = getAndRemoveAttr(el, name).has + } while (has) + + if (!resultName) { + // 清除修饰符 + resultName = name.replace(/\..*/, '') + } + } + }) + return { resultName } +} + function processEvent (el, options) { const eventConfigMap = {} el.attrsList.forEach(function ({ name, value }) { @@ -1374,22 +1400,11 @@ function processEvent (el, options) { } for (const type in eventConfigMap) { - let needBubblingBind = false - let needCaptureBind = false const { configs = [], captureConfigs = [], proxy } = eventConfigMap[type] delete eventConfigMap[type] - if (proxy) { - needBubblingBind = true - needCaptureBind = true - } else if (configs.length > 1) { - needBubblingBind = true - } else if (captureConfigs.length > 1) { - needCaptureBind = true - } else if (configs.length === 1) { - needBubblingBind = !!configs[0].hasArgs - } else if (captureConfigs.length === 1) { - needCaptureBind = !!captureConfigs[0].hasArgs - } + + let needBubblingBind = isNeedBind(configs, proxy) + let needCaptureBind = isNeedBind(captureConfigs, proxy) const escapedType = dash2hump(type) // 排除特殊情况 @@ -1400,21 +1415,7 @@ function processEvent (el, options) { } if (needBubblingBind) { - let resultName - configs.forEach(({ name }) => { - if (name) { - // 清空原始事件绑定 - let has - do { - has = getAndRemoveAttr(el, name).has - } while (has) - - if (!resultName) { - // 清除修饰符 - resultName = name.replace(/\..*/, '') - } - } - }) + const { resultName } = processEventBinding(el, configs) addAttrs(el, [ { @@ -1422,36 +1423,25 @@ function processEvent (el, options) { value: '__invoke' } ]) - eventConfigMap.bubble = {} + if (!eventConfigMap.bubble) { + eventConfigMap.bubble = {} + } eventConfigMap.bubble[escapedType] = configs.map((item) => { return item.expStr }) } if (needCaptureBind) { - let resultName - captureConfigs.forEach(({ name }) => { - if (name) { - // 清空原始事件绑定 - let has - do { - has = getAndRemoveAttr(el, name).has - } while (has) - - if (!resultName) { - // 清除修饰符 - resultName = name.replace(/\..*/, '') - } - } - }) - + const { resultName } = processEventBinding(el, captureConfigs) addAttrs(el, [ { name: resultName || config[mode].event.getEvent(type), value: '__captureInvoke' } ]) - eventConfigMap.capture = {} + if (!eventConfigMap.capture) { + eventConfigMap.capture = {} + } eventConfigMap.capture[escapedType] = captureConfigs.map((item) => { return item.expStr }) From a5f608c711946e745a3fe8577cba052ce2affee7 Mon Sep 17 00:00:00 2001 From: lareinayanyu Date: Wed, 15 Jan 2025 14:48:14 +0800 Subject: [PATCH 6/6] fix: lint --- .../platform/builtInMixins/proxyEventMixin.js | 23 ++++--------------- 1 file changed, 5 insertions(+), 18 deletions(-) diff --git a/packages/core/src/platform/builtInMixins/proxyEventMixin.js b/packages/core/src/platform/builtInMixins/proxyEventMixin.js index 2057a6e1d1..b645dbc304 100644 --- a/packages/core/src/platform/builtInMixins/proxyEventMixin.js +++ b/packages/core/src/platform/builtInMixins/proxyEventMixin.js @@ -88,31 +88,18 @@ export default function proxyEventMixin () { }, __model (expr, $event, valuePath = ['value'], filterMethod) { const innerFilter = { - trim: (val) => typeof val === 'string' && val.trim() + trim: val => typeof val === 'string' && val.trim() } - const originValue = valuePath.reduce( - (acc, cur) => acc[cur], - $event.detail - ) - const value = filterMethod - ? innerFilter[filterMethod] - ? innerFilter[filterMethod](originValue) - : typeof this[filterMethod] === 'function' - ? this[filterMethod](originValue) - : originValue - : originValue + const originValue = valuePath.reduce((acc, cur) => acc[cur], $event.detail) + const value = filterMethod ? (innerFilter[filterMethod] ? innerFilter[filterMethod](originValue) : typeof this[filterMethod] === 'function' ? this[filterMethod](originValue) : originValue) : originValue setByPath(this, expr, value) } } if (__mpx_mode__ === 'ali') { Object.assign(methods, { triggerEvent (eventName, eventDetail) { - const handlerName = eventName - .replace(/^./, (matched) => matched.toUpperCase()) - .replace(/-([a-z])/g, (match, p1) => p1.toUpperCase()) - const handler = - this.props && - (this.props['on' + handlerName] || this.props['catch' + handlerName]) + const handlerName = eventName.replace(/^./, matched => matched.toUpperCase()).replace(/-([a-z])/g, (match, p1) => p1.toUpperCase()) + const handler = this.props && (this.props['on' + handlerName] || this.props['catch' + handlerName]) if (handler && typeof handler === 'function') { const dataset = collectDataset(this.props) const id = this.props.id || ''