@mpxjs/core 2.7.33 → 2.7.37

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mpxjs/core",
3
- "version": "2.7.33",
3
+ "version": "2.7.37",
4
4
  "description": "mpx runtime core",
5
5
  "keywords": [
6
6
  "miniprogram",
@@ -41,5 +41,5 @@
41
41
  "url": "https://github.com/didi/mpx/issues"
42
42
  },
43
43
  "sideEffects": false,
44
- "gitHead": "c1d2e39bcfef9bf20484dcbb301381b86a5939e6"
44
+ "gitHead": "b39b466d24c97264ee096c91747dbb922422b122"
45
45
  }
@@ -70,10 +70,13 @@ export default function proxyEventMixin () {
70
70
  }
71
71
  }
72
72
  if (__mpx_mode__ === 'ali') {
73
+ const getHandler = (eventName, props) => {
74
+ const handlerName = eventName.replace(/^./, matched => matched.toUpperCase()).replace(/-([a-z])/g, (match, p1) => p1.toUpperCase())
75
+ return props && (props['on' + handlerName] || props['catch' + handlerName])
76
+ }
73
77
  Object.assign(methods, {
74
78
  triggerEvent (eventName, eventDetail) {
75
- const handlerName = eventName.replace(/^./, matched => matched.toUpperCase()).replace(/-([a-z])/g, (match, p1) => p1.toUpperCase())
76
- const handler = this.props && (this.props['on' + handlerName] || this.props['catch' + handlerName])
79
+ const handler = getHandler(eventName, this.props)
77
80
  if (handler && typeof handler === 'function') {
78
81
  const dataset = collectDataset(this.props)
79
82
  const id = this.props.id || ''
@@ -92,6 +95,31 @@ export default function proxyEventMixin () {
92
95
  },
93
96
  detail: eventDetail
94
97
  }
98
+ handler.call(this, eventObj)
99
+ }
100
+ },
101
+ __proxyEvent (e) {
102
+ const type = e.type
103
+ const handler = getHandler(type, this.props)
104
+
105
+ if (handler && typeof handler === 'function') {
106
+ const dataset = collectDataset(this.props)
107
+ const id = this.props.id || ''
108
+ const targetData = Object.assign({}, e.target || {}, {
109
+ id,
110
+ dataset
111
+ })
112
+
113
+ const currentTargetData = Object.assign({}, e.currentTarget || {}, {
114
+ id,
115
+ dataset
116
+ })
117
+
118
+ const eventObj = Object.assign({}, e, {
119
+ target: targetData,
120
+ currentTarget: currentTargetData
121
+ })
122
+
95
123
  handler.call(this, eventObj)
96
124
  }
97
125
  }