@mpxjs/core 2.8.18 → 2.8.19
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.19",
|
|
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": "fca1b61f52c2ed8b3926e7b8a3a150d27904911a"
|
|
51
51
|
}
|
package/src/core/mergeOptions.js
CHANGED
|
@@ -47,7 +47,7 @@ export default function mergeOptions (options = {}, type, needConvert) {
|
|
|
47
47
|
|
|
48
48
|
export function getMixin (mixin = {}) {
|
|
49
49
|
// 用于ts反向推导mixin类型
|
|
50
|
-
return mixin
|
|
50
|
+
return mixin
|
|
51
51
|
}
|
|
52
52
|
|
|
53
53
|
function extractMixins (mergeOptions, options, needConvert) {
|
|
@@ -214,7 +214,7 @@ function mergeMixins (parent, child) {
|
|
|
214
214
|
mergeHooks(parent, child, key)
|
|
215
215
|
} else if (/^(data|dataFn)$/.test(key)) {
|
|
216
216
|
mergeDataFn(parent, child, key)
|
|
217
|
-
} else if (/^(computed|properties|props|methods|proto|options|relations)$/.test(key)) {
|
|
217
|
+
} else if (/^(computed|properties|props|methods|proto|options|relations|initData)$/.test(key)) {
|
|
218
218
|
mergeShallowObj(parent, child, key)
|
|
219
219
|
} else if (/^(watch|observers|pageLifetimes|events)$/.test(key)) {
|
|
220
220
|
mergeToArray(parent, child, key)
|
|
@@ -74,8 +74,14 @@ function filterOptions (options, type) {
|
|
|
74
74
|
if (builtInKeysMap[key]) {
|
|
75
75
|
return
|
|
76
76
|
}
|
|
77
|
-
if (key === '
|
|
78
|
-
|
|
77
|
+
if (key === 'data' || key === 'initData') {
|
|
78
|
+
if (!hasOwn(newOptions, 'data')) {
|
|
79
|
+
newOptions.data = Object.assign({}, options.initData, options.data)
|
|
80
|
+
}
|
|
81
|
+
} else if (key === 'properties' || key === 'props') {
|
|
82
|
+
if (!hasOwn(newOptions, 'props')) {
|
|
83
|
+
newOptions.props = Object.assign({}, options.props, options.properties)
|
|
84
|
+
}
|
|
79
85
|
} else if (key === 'methods' && type === 'page') {
|
|
80
86
|
Object.assign(newOptions, options[key])
|
|
81
87
|
} else {
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { INNER_LIFECYCLES } from '../../core/innerLifecycle'
|
|
2
2
|
import { makeMap } from '@mpxjs/utils'
|
|
3
3
|
|
|
4
|
-
let
|
|
4
|
+
let builtInKeys
|
|
5
5
|
|
|
6
6
|
if (__mpx_mode__ === 'web') {
|
|
7
|
-
|
|
7
|
+
builtInKeys = [
|
|
8
8
|
'proto',
|
|
9
9
|
'mixins',
|
|
10
10
|
'mpxCustomKeysForBlend',
|
|
@@ -15,7 +15,7 @@ if (__mpx_mode__ === 'web') {
|
|
|
15
15
|
'__pageCtor__'
|
|
16
16
|
]
|
|
17
17
|
} else {
|
|
18
|
-
|
|
18
|
+
builtInKeys = [
|
|
19
19
|
'setup',
|
|
20
20
|
'dataFn',
|
|
21
21
|
'proto',
|
|
@@ -31,4 +31,4 @@ if (__mpx_mode__ === 'web') {
|
|
|
31
31
|
]
|
|
32
32
|
}
|
|
33
33
|
|
|
34
|
-
export default makeMap(
|
|
34
|
+
export default makeMap(builtInKeys.concat(INNER_LIFECYCLES))
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import builtInKeysMap from '../builtInKeysMap'
|
|
2
2
|
import mergeOptions from '../../../core/mergeOptions'
|
|
3
|
-
import { diffAndCloneA } from '@mpxjs/utils'
|
|
3
|
+
import { diffAndCloneA, hasOwn } from '@mpxjs/utils'
|
|
4
4
|
import { getCurrentInstance as getCurrentVueInstance } from '../../export/index'
|
|
5
5
|
import MpxProxy, { setCurrentInstance, unsetCurrentInstance } from '../../../core/proxy'
|
|
6
6
|
import { BEFOREUPDATE, UPDATED, BEFOREUNMOUNT, UNMOUNTED } from '../../../core/innerLifecycle'
|
|
@@ -12,11 +12,13 @@ function filterOptions (options) {
|
|
|
12
12
|
return
|
|
13
13
|
}
|
|
14
14
|
if (key === 'data' || key === 'dataFn') {
|
|
15
|
-
newOptions
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
15
|
+
if (!hasOwn(newOptions, 'data')) {
|
|
16
|
+
newOptions.data = function mergeFn () {
|
|
17
|
+
return Object.assign(
|
|
18
|
+
diffAndCloneA(options.data || {}).clone,
|
|
19
|
+
options.dataFn && options.dataFn.call(this)
|
|
20
|
+
)
|
|
21
|
+
}
|
|
20
22
|
}
|
|
21
23
|
} else {
|
|
22
24
|
newOptions[key] = options[key]
|
|
@@ -112,8 +112,14 @@ export function filterOptions (options) {
|
|
|
112
112
|
if (builtInKeysMap[key]) {
|
|
113
113
|
return
|
|
114
114
|
}
|
|
115
|
-
if (key === '
|
|
116
|
-
|
|
115
|
+
if (key === 'data' || key === 'initData') {
|
|
116
|
+
if (!hasOwn(newOptions, 'data')) {
|
|
117
|
+
newOptions.data = Object.assign({}, options.initData, options.data)
|
|
118
|
+
}
|
|
119
|
+
} else if (key === 'properties' || key === 'props') {
|
|
120
|
+
if (!hasOwn(newOptions, 'properties')) {
|
|
121
|
+
newOptions.properties = transformProperties(Object.assign({}, options.props, options.properties))
|
|
122
|
+
}
|
|
117
123
|
} else if (key === 'methods' && options.__pageCtor__) {
|
|
118
124
|
// 构造器为Page时抽取所有methods方法到顶层
|
|
119
125
|
Object.assign(newOptions, options[key])
|