@mpxjs/core 2.8.50 → 2.8.51
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.8.
|
|
3
|
+
"version": "2.8.51",
|
|
4
4
|
"description": "mpx runtime core",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"miniprogram",
|
|
@@ -47,5 +47,5 @@
|
|
|
47
47
|
"url": "https://github.com/didi/mpx/issues"
|
|
48
48
|
},
|
|
49
49
|
"sideEffects": false,
|
|
50
|
-
"gitHead": "
|
|
50
|
+
"gitHead": "7b9523688cc1cf8077d8705e64ea5a742dccff13"
|
|
51
51
|
}
|
package/src/core/injectMixins.js
CHANGED
|
@@ -89,29 +89,34 @@ export default function proxyEventMixin () {
|
|
|
89
89
|
}
|
|
90
90
|
if (__mpx_mode__ === 'ali') {
|
|
91
91
|
Object.assign(methods, {
|
|
92
|
-
triggerEvent (eventName, eventDetail) {
|
|
92
|
+
triggerEvent (eventName, eventDetail, e) {
|
|
93
93
|
const handlerName = eventName.replace(/^./, matched => matched.toUpperCase()).replace(/-([a-z])/g, (match, p1) => p1.toUpperCase())
|
|
94
94
|
const handler = this.props && (this.props['on' + handlerName] || this.props['catch' + handlerName])
|
|
95
95
|
if (handler && typeof handler === 'function') {
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
id,
|
|
109
|
-
|
|
110
|
-
}
|
|
111
|
-
detail: eventDetail
|
|
96
|
+
let eventObj = {}
|
|
97
|
+
if (e) {
|
|
98
|
+
e.detail = Object.assign(e.detail, eventDetail)
|
|
99
|
+
eventObj = e
|
|
100
|
+
} else {
|
|
101
|
+
const dataset = collectDataset(this.props)
|
|
102
|
+
const id = this.props.id || ''
|
|
103
|
+
const timeStamp = +new Date()
|
|
104
|
+
eventObj = {
|
|
105
|
+
type: eventName,
|
|
106
|
+
timeStamp,
|
|
107
|
+
target: { id, dataset, targetDataset: dataset },
|
|
108
|
+
currentTarget: { id, dataset },
|
|
109
|
+
detail: eventDetail
|
|
110
|
+
}
|
|
112
111
|
}
|
|
113
112
|
handler.call(this, eventObj)
|
|
114
113
|
}
|
|
114
|
+
},
|
|
115
|
+
__proxyEvent (e) {
|
|
116
|
+
const eventName = e.type
|
|
117
|
+
// 保持和微信一致
|
|
118
|
+
e.target = e.currentTarget
|
|
119
|
+
this.triggerEvent(eventName, {}, e)
|
|
115
120
|
}
|
|
116
121
|
})
|
|
117
122
|
}
|
|
@@ -18,6 +18,12 @@ export default function proxyEventMixin () {
|
|
|
18
18
|
const originValue = valuePath.reduce((acc, cur) => acc[cur], $event.detail)
|
|
19
19
|
const value = filterMethod ? (innerFilter[filterMethod] ? innerFilter[filterMethod](originValue) : typeof this[filterMethod] === 'function' && this[filterMethod]) : originValue
|
|
20
20
|
setByPath(this, expr, value)
|
|
21
|
+
},
|
|
22
|
+
__proxyEvent (e) {
|
|
23
|
+
const type = e.type
|
|
24
|
+
// 保持和微信一致 target 和 currentTarget 相同
|
|
25
|
+
e.target = e.currentTarget
|
|
26
|
+
this.triggerEvent(type, {}, e)
|
|
21
27
|
}
|
|
22
28
|
}
|
|
23
29
|
}
|
package/src/vuePlugin.js
CHANGED
|
@@ -1,12 +1,39 @@
|
|
|
1
|
-
import { walkChildren, parseSelector, error } from '@mpxjs/utils'
|
|
1
|
+
import { walkChildren, parseSelector, error, hasOwn } from '@mpxjs/utils'
|
|
2
2
|
import * as webApi from '@mpxjs/api-proxy/src/web/api'
|
|
3
|
+
const datasetReg = /^data-(.+)$/
|
|
4
|
+
|
|
5
|
+
function collectDataset (attrs) {
|
|
6
|
+
const dataset = {}
|
|
7
|
+
for (const key in attrs) {
|
|
8
|
+
if (hasOwn(attrs, key)) {
|
|
9
|
+
const matched = datasetReg.exec(key)
|
|
10
|
+
if (matched) {
|
|
11
|
+
dataset[matched[1]] = attrs[key]
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
return dataset
|
|
16
|
+
}
|
|
3
17
|
|
|
4
18
|
export default function install (Vue) {
|
|
5
|
-
Vue.prototype.triggerEvent = function (eventName, eventDetail) {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
detail
|
|
9
|
-
|
|
19
|
+
Vue.prototype.triggerEvent = function (eventName, eventDetail, e) {
|
|
20
|
+
let eventObj = {}
|
|
21
|
+
if (e) {
|
|
22
|
+
e.detail = Object.assign(e.detail, eventDetail)
|
|
23
|
+
eventObj = e
|
|
24
|
+
} else {
|
|
25
|
+
const dataset = collectDataset(this.$attrs)
|
|
26
|
+
const id = this.$attrs.id || ''
|
|
27
|
+
const timeStamp = +new Date()
|
|
28
|
+
eventObj = {
|
|
29
|
+
type: eventName,
|
|
30
|
+
timeStamp,
|
|
31
|
+
target: { id, dataset, targetDataset: dataset },
|
|
32
|
+
currentTarget: { id, dataset },
|
|
33
|
+
detail: eventDetail
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
return this.$emit(eventName, eventObj)
|
|
10
37
|
}
|
|
11
38
|
Vue.prototype.selectComponent = function (selector, all) {
|
|
12
39
|
const result = []
|