@mpxjs/core 2.8.59 → 2.8.61
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 +3 -3
- package/src/core/proxy.js +15 -2
- package/src/platform/builtInMixins/proxyEventMixin.js +3 -1
- package/src/platform/builtInMixins/renderHelperMixin.js +12 -1
- package/src/platform/patch/ali/getDefaultOptions.js +9 -11
- package/src/platform/patch/wx/getDefaultOptions.js +9 -11
- package/src/vuePlugin.js +5 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mpxjs/core",
|
|
3
|
-
"version": "2.8.
|
|
3
|
+
"version": "2.8.61",
|
|
4
4
|
"description": "mpx runtime core",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"miniprogram",
|
|
@@ -19,7 +19,7 @@
|
|
|
19
19
|
],
|
|
20
20
|
"main": "src/index.js",
|
|
21
21
|
"dependencies": {
|
|
22
|
-
"@mpxjs/utils": "^2.8.
|
|
22
|
+
"@mpxjs/utils": "^2.8.60",
|
|
23
23
|
"lodash": "^4.1.1",
|
|
24
24
|
"miniprogram-api-typings": "^3.10.0"
|
|
25
25
|
},
|
|
@@ -47,5 +47,5 @@
|
|
|
47
47
|
"url": "https://github.com/didi/mpx/issues"
|
|
48
48
|
},
|
|
49
49
|
"sideEffects": false,
|
|
50
|
-
"gitHead": "
|
|
50
|
+
"gitHead": "f393ffc439f21b24f5f09a65ef99db20b145e19a"
|
|
51
51
|
}
|
package/src/core/proxy.js
CHANGED
|
@@ -311,7 +311,16 @@ export default class MpxProxy {
|
|
|
311
311
|
watch (source, cb, options) {
|
|
312
312
|
const target = this.target
|
|
313
313
|
const getter = isString(source)
|
|
314
|
-
? () =>
|
|
314
|
+
? () => {
|
|
315
|
+
// for watch multi path string like 'a.b,c,d'
|
|
316
|
+
if (source.indexOf(',') > -1) {
|
|
317
|
+
return source.split(',').map(path => {
|
|
318
|
+
return getByPath(target, path.trim())
|
|
319
|
+
})
|
|
320
|
+
} else {
|
|
321
|
+
return getByPath(target, source)
|
|
322
|
+
}
|
|
323
|
+
}
|
|
315
324
|
: source.bind(target)
|
|
316
325
|
|
|
317
326
|
if (isObject(cb)) {
|
|
@@ -529,6 +538,10 @@ export default class MpxProxy {
|
|
|
529
538
|
initRender () {
|
|
530
539
|
if (this.options.__nativeRender__) return this.doRender()
|
|
531
540
|
|
|
541
|
+
const _i = this.target._i.bind(this.target)
|
|
542
|
+
const _c = this.target._c.bind(this.target)
|
|
543
|
+
const _r = this.target._r.bind(this.target)
|
|
544
|
+
const _sc = this.target._sc.bind(this.target)
|
|
532
545
|
const effect = this.effect = new ReactiveEffect(() => {
|
|
533
546
|
// pre render for props update
|
|
534
547
|
if (this.propsUpdatedFlag) {
|
|
@@ -537,7 +550,7 @@ export default class MpxProxy {
|
|
|
537
550
|
|
|
538
551
|
if (this.target.__injectedRender) {
|
|
539
552
|
try {
|
|
540
|
-
return this.target.__injectedRender()
|
|
553
|
+
return this.target.__injectedRender(_i, _c, _r, _sc)
|
|
541
554
|
} catch (e) {
|
|
542
555
|
warn('Failed to execute render function, degrade to full-set-data mode.', this.options.mpxFileResource, e)
|
|
543
556
|
this.render()
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { setByPath, error, hasOwn } from '@mpxjs/utils'
|
|
1
|
+
import { setByPath, error, hasOwn, dash2hump } from '@mpxjs/utils'
|
|
2
2
|
import Mpx from '../../index'
|
|
3
3
|
|
|
4
4
|
const datasetReg = /^data-(.+)$/
|
|
@@ -36,6 +36,8 @@ export default function proxyEventMixin () {
|
|
|
36
36
|
if (type === 'begin' || type === 'end') {
|
|
37
37
|
// 地图的 regionchange 事件会派发 e.type 为 begin 和 end 的事件
|
|
38
38
|
fallbackType = 'regionchange'
|
|
39
|
+
} else if (/-([a-z])/.test(type)) {
|
|
40
|
+
fallbackType = dash2hump(type)
|
|
39
41
|
} else if (__mpx_mode__ === 'ali') {
|
|
40
42
|
fallbackType = type.replace(/^./, i => i.toLowerCase())
|
|
41
43
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { isObject } from '@mpxjs/utils'
|
|
1
|
+
import { getByPath, hasOwn, isObject } from '@mpxjs/utils'
|
|
2
2
|
|
|
3
3
|
export default function renderHelperMixin () {
|
|
4
4
|
return {
|
|
@@ -21,10 +21,21 @@ export default function renderHelperMixin () {
|
|
|
21
21
|
}
|
|
22
22
|
}
|
|
23
23
|
},
|
|
24
|
+
// collect
|
|
24
25
|
_c (key, value) {
|
|
26
|
+
if (hasOwn(this.__mpxProxy.renderData, key)) {
|
|
27
|
+
return this.__mpxProxy.renderData[key]
|
|
28
|
+
}
|
|
29
|
+
if (value === undefined) {
|
|
30
|
+
value = getByPath(this, key)
|
|
31
|
+
}
|
|
25
32
|
this.__mpxProxy.renderData[key] = value
|
|
26
33
|
return value
|
|
27
34
|
},
|
|
35
|
+
// simple collect
|
|
36
|
+
_sc (key) {
|
|
37
|
+
return (this.__mpxProxy.renderData[key] = this[key])
|
|
38
|
+
},
|
|
28
39
|
_r () {
|
|
29
40
|
this.__mpxProxy.renderWithData()
|
|
30
41
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import MpxProxy from '../../../core/proxy'
|
|
2
2
|
import builtInKeysMap from '../builtInKeysMap'
|
|
3
3
|
import mergeOptions from '../../../core/mergeOptions'
|
|
4
|
-
import { isFunction, error, diffAndCloneA, hasOwn } from '@mpxjs/utils'
|
|
4
|
+
import { isFunction, error, diffAndCloneA, hasOwn, noop } from '@mpxjs/utils'
|
|
5
5
|
|
|
6
6
|
function transformApiForProxy (context, currentInject) {
|
|
7
7
|
const rawSetData = context.setData.bind(context)
|
|
@@ -45,16 +45,14 @@ function transformApiForProxy (context, currentInject) {
|
|
|
45
45
|
}
|
|
46
46
|
})
|
|
47
47
|
if (currentInject) {
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
})
|
|
57
|
-
}
|
|
48
|
+
Object.defineProperties(context, {
|
|
49
|
+
__injectedRender: {
|
|
50
|
+
get () {
|
|
51
|
+
return currentInject.render || noop
|
|
52
|
+
},
|
|
53
|
+
configurable: false
|
|
54
|
+
}
|
|
55
|
+
})
|
|
58
56
|
if (currentInject.getRefsData) {
|
|
59
57
|
Object.defineProperties(context, {
|
|
60
58
|
__getRefsData: {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { hasOwn } from '@mpxjs/utils'
|
|
1
|
+
import { hasOwn, noop } from '@mpxjs/utils'
|
|
2
2
|
import MpxProxy from '../../../core/proxy'
|
|
3
3
|
import builtInKeysMap from '../builtInKeysMap'
|
|
4
4
|
import mergeOptions from '../../../core/mergeOptions'
|
|
@@ -83,16 +83,14 @@ function transformApiForProxy (context, currentInject) {
|
|
|
83
83
|
|
|
84
84
|
// 绑定注入的render
|
|
85
85
|
if (currentInject) {
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
})
|
|
95
|
-
}
|
|
86
|
+
Object.defineProperties(context, {
|
|
87
|
+
__injectedRender: {
|
|
88
|
+
get () {
|
|
89
|
+
return currentInject.render || noop
|
|
90
|
+
},
|
|
91
|
+
configurable: false
|
|
92
|
+
}
|
|
93
|
+
})
|
|
96
94
|
if (currentInject.getRefsData) {
|
|
97
95
|
Object.defineProperties(context, {
|
|
98
96
|
__getRefsData: {
|
package/src/vuePlugin.js
CHANGED
|
@@ -17,6 +17,11 @@ function collectDataset (attrs) {
|
|
|
17
17
|
|
|
18
18
|
export default function install (Vue) {
|
|
19
19
|
Vue.prototype.triggerEvent = function (eventName, eventDetail) {
|
|
20
|
+
// 输出Web时自定义组件绑定click事件会和web原生事件冲突,组件内部triggerEvent时会导致事件执行两次,将click事件改为_click来规避此问题
|
|
21
|
+
const escapeEvents = ['click']
|
|
22
|
+
if (escapeEvents.includes(eventName)) {
|
|
23
|
+
eventName = '_' + eventName
|
|
24
|
+
}
|
|
20
25
|
let eventObj = {}
|
|
21
26
|
const dataset = collectDataset(this.$attrs)
|
|
22
27
|
const id = this.$attrs.id || ''
|