resolver-egretimp-plus 0.0.138 → 0.0.139

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": "resolver-egretimp-plus",
3
- "version": "0.0.138",
3
+ "version": "0.0.139",
4
4
  "description": "交付体验渲染",
5
5
  "main": "./dist/web/index.js",
6
6
  "module": "./dist/web/index.js",
@@ -64,13 +64,26 @@ export function useVModel(config, props, emit, modelKey = 'update:modelValue') {
64
64
  const metaCode = metaCodeKey
65
65
  if (!metaCode) return
66
66
  if (!modelValue) {
67
+ // frameSet 表示的是一帧之内重复设置对应metaCode的值
68
+ // 一帧之内重复设置metaCode的值需要进行merge,也就是下面modelValueDeepMerge走的逻辑
69
+ //(
70
+ // 原因是因为一帧之后重复设置,如果不走merge,会出现val值直接覆盖原本对应的metaCode的值,
71
+ // 这个在正常情况下没什么问题,但是如果刚开始根数据对应的层级对应出现断层为空,在进行emit(update:modelValue)进行赋值之后
72
+ // 并不能立即更新到对应的props.modelValue下面去,所以会出现 同时通过config.refValue设置同层级,并且是根数据断层的情况下;会出现覆盖
73
+ // )
74
+ config.parent && (config.parent.frameSet = true)
75
+ nextTick(() => {
76
+ config.parent && (config.parent.frameSet = false)
77
+ })
67
78
  emit('update:modelValue', {
68
79
  [metaCode]: val
69
80
  })
70
81
  } else {
71
- if (modelValue?.[metaCode]) {
72
- if (typeof modelValue[metaCode] === 'object' || typeof val === 'object') {
73
- val = modelValueDeepMerge(val, modelValue[metaCode])
82
+ if (config?.frameSet) {
83
+ if (modelValue?.[metaCode]) {
84
+ if (typeof modelValue[metaCode] === 'object' || typeof val === 'object') {
85
+ val = modelValueDeepMerge(modelValue[metaCode], val)
86
+ }
74
87
  }
75
88
  }
76
89
  if (isNonRefType(modelValue[metaCode]) && isNonRefType(val) && modelValue[metaCode] === val) {
@@ -214,37 +214,29 @@ export function modelValueDeepMerge(
214
214
  source,
215
215
  target,
216
216
  ) {
217
- if (!target) {
218
- return source;
219
- }
220
- if (!source) {
221
- return target;
222
- }
223
- let ret = mergeWith(source, target, (sourceValue, targetValue) => {
224
- if (!targetValue) {
225
- return sourceValue
226
- }
227
- if (!sourceValue) {
228
- return targetValue
229
- }
230
- if (isArray(sourceValue) && isArray(targetValue)) {
231
- const ret = []
232
- let idx = 0
233
- for(;idx < sourceValue.length && idx < targetValue.length; i ++) {
234
- ret.push(modelValueDeepMerge[sourceValue[idx], targetValue[idx]])
217
+ let ret = target
218
+ if (typeof source === 'object' && typeof target === 'object') {
219
+ ret = mergeWith(source, target, (sourceValue, targetValue) => {
220
+ if (isArray(sourceValue) && isArray(targetValue)) {
221
+ const ret = []
222
+ let idx = 0
223
+ for(;idx < sourceValue.length && idx < targetValue.length; i ++) {
224
+ ret.push(modelValueDeepMerge[sourceValue[idx], targetValue[idx]])
225
+ }
226
+ if (idx < sourceValue.length) {
227
+ ret.push(...sourceValue.slice(idx))
228
+ } else {
229
+ ret.push(...targetValue.slice(idx))
230
+ }
231
+ return ret
235
232
  }
236
- if (idx < sourceValue.length) {
237
- ret.push(...sourceValue.slice(idx))
238
- } else {
239
- ret.push(...targetValue.slice(idx))
233
+ if (isPlainObject(targetValue) && isPlainObject(sourceValue)) {
234
+ return modelValueDeepMerge(sourceValue, targetValue);
240
235
  }
241
- return ret
242
- }
243
- if (isPlainObject(targetValue) && isPlainObject(sourceValue)) {
244
- return deepMerge(sourceValue, targetValue, mergeArrays);
245
- }
246
- return targetValue;
247
- });
236
+ return targetValue;
237
+ });
238
+ }
239
+
248
240
  if (Array.isArray(source)) {
249
241
  if (ret && !Array.isArray(ret)) {
250
242
  let arr = []