(val: IPublicTypeCompositeValue)
| 352 | */ |
| 353 | @action |
| 354 | setValue(val: IPublicTypeCompositeValue) { |
| 355 | if (val === this._value) return; |
| 356 | const oldValue = this._value; |
| 357 | this._value = val; |
| 358 | this._code = null; |
| 359 | const t = typeof val; |
| 360 | if (val == null) { |
| 361 | // this._value = undefined; |
| 362 | this._type = 'literal'; |
| 363 | } else if (t === 'string' || t === 'number' || t === 'boolean') { |
| 364 | this._type = 'literal'; |
| 365 | } else if (Array.isArray(val)) { |
| 366 | this._type = 'list'; |
| 367 | } else if (isPlainObject(val)) { |
| 368 | if (isJSSlot(val)) { |
| 369 | this.setAsSlot(val); |
| 370 | } else if (isJSExpression(val)) { |
| 371 | this._type = 'expression'; |
| 372 | } else { |
| 373 | this._type = 'map'; |
| 374 | } |
| 375 | } else /* istanbul ignore next */ { |
| 376 | this._type = 'expression'; |
| 377 | this._value = { |
| 378 | type: 'JSExpression', |
| 379 | value: valueToSource(val), |
| 380 | }; |
| 381 | } |
| 382 | |
| 383 | this.dispose(); |
| 384 | // setValue 的时候,如果不重新建立 items,items 的 setValue 没有触发,会导致子项的响应式逻辑不能被触发 |
| 385 | this.setupItems(); |
| 386 | |
| 387 | if (oldValue !== this._value) { |
| 388 | this.emitChange({ oldValue }); |
| 389 | } |
| 390 | } |
| 391 | |
| 392 | emitChange = ({ |
| 393 | oldValue, |
no test coverage detected