* @internal
(
key: string,
val: any,
shouldReflect = true,
shouldUpdate = false,
)
| 509 | * @internal |
| 510 | */ |
| 511 | _setProp( |
| 512 | key: string, |
| 513 | val: any, |
| 514 | shouldReflect = true, |
| 515 | shouldUpdate = false, |
| 516 | ): void { |
| 517 | if (val !== this._props[key]) { |
| 518 | this._dirty = true |
| 519 | if (val === REMOVAL) { |
| 520 | delete this._props[key] |
| 521 | } else { |
| 522 | this._props[key] = val |
| 523 | // support set key on ceVNode |
| 524 | if (key === 'key' && this._app) { |
| 525 | this._app._ceVNode!.key = val |
| 526 | } |
| 527 | } |
| 528 | if (shouldUpdate && this._instance) { |
| 529 | this._update() |
| 530 | } |
| 531 | // reflect |
| 532 | if (shouldReflect) { |
| 533 | const ob = this._ob |
| 534 | if (ob) { |
| 535 | this._processMutations(ob.takeRecords()) |
| 536 | ob.disconnect() |
| 537 | } |
| 538 | if (val === true) { |
| 539 | this.setAttribute(hyphenate(key), '') |
| 540 | } else if (typeof val === 'string' || typeof val === 'number') { |
| 541 | this.setAttribute(hyphenate(key), val + '') |
| 542 | } else if (!val) { |
| 543 | this.removeAttribute(hyphenate(key)) |
| 544 | } |
| 545 | ob && ob.observe(this, { attributes: true }) |
| 546 | } |
| 547 | } |
| 548 | } |
| 549 | |
| 550 | private _update() { |
| 551 | const vnode = this._createVNode() |
no test coverage detected