@mpxjs/core 2.7.29 → 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.
|
|
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": "
|
|
44
|
+
"gitHead": "b39b466d24c97264ee096c91747dbb922422b122"
|
|
45
45
|
}
|
package/src/core/proxy.js
CHANGED
|
@@ -35,7 +35,7 @@ export default function pageStatusMixin (mixinType) {
|
|
|
35
35
|
[CREATED] () {
|
|
36
36
|
const options = this.$rawOptions
|
|
37
37
|
const hasPageShow = options.pageShow || options.pageHide
|
|
38
|
-
const needPageLifetimes = options.pageLifetimes &&
|
|
38
|
+
const needPageLifetimes = options.pageLifetimes && __mpx_mode__ === 'ali'
|
|
39
39
|
|
|
40
40
|
if (hasPageShow || needPageLifetimes) {
|
|
41
41
|
let currentPage
|
|
@@ -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
|
|
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
|
}
|
|
@@ -22,7 +22,8 @@ const setComponentRef = function (target, ref, context, isAsync) {
|
|
|
22
22
|
enumerable: true,
|
|
23
23
|
configurable: true,
|
|
24
24
|
get () {
|
|
25
|
-
|
|
25
|
+
// wx由于分包异步化的存在,每次访问refs都需要重新执行selectComponen,避免一直拿到缓存中的placeholder
|
|
26
|
+
if (__mpx_mode__ === 'wx' || !cacheRef) {
|
|
26
27
|
return (cacheRef = context.__getRefNode(ref, isAsync))
|
|
27
28
|
}
|
|
28
29
|
return cacheRef
|