From: daiwei Date: Tue, 8 Oct 2024 11:57:38 +0000 (+0800) Subject: chore: update X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=b44f0c715b9c718021169cee5a21a6dacf18d1e8;p=thirdparty%2Fvuejs%2Fcore.git chore: update --- diff --git a/packages/runtime-dom/__tests__/customElement.spec.ts b/packages/runtime-dom/__tests__/customElement.spec.ts index 68e0f55a06..9d2e14d3d7 100644 --- a/packages/runtime-dom/__tests__/customElement.spec.ts +++ b/packages/runtime-dom/__tests__/customElement.spec.ts @@ -1401,7 +1401,7 @@ describe('defineCustomElement', () => { customElements.define('el-attr-tag-name', E) container.innerHTML = '' const e = container.childNodes[0] as VueElement + expect(e.shadowRoot!.innerHTML).toBe(`foo`) expect(e.tagName).toBe(`EL-ATTR-TAG-NAME`) - expect(`[Vue warn]: Failed setting prop "tagName" `).toHaveBeenWarned() }) }) diff --git a/packages/runtime-dom/src/apiCustomElement.ts b/packages/runtime-dom/src/apiCustomElement.ts index a0a8a3a7c3..46238bdb00 100644 --- a/packages/runtime-dom/src/apiCustomElement.ts +++ b/packages/runtime-dom/src/apiCustomElement.ts @@ -451,13 +451,15 @@ export class VueElement } // defining getter/setters on prototype + const propValue: Record = {} for (const key of declaredPropKeys.map(camelize)) { - if (key === 'tagName') continue + if (key in this) propValue[key] = this[key as keyof this] Object.defineProperty(this, key, { get() { - return this._getProp(key) + return key in propValue ? propValue[key] : this._getProp(key) }, set(val) { + if (key in this) propValue[key] = val this._setProp(key, val, true, true) }, }) @@ -491,15 +493,6 @@ export class VueElement shouldReflect = true, shouldUpdate = false, ): void { - if (key === 'tagName') { - if (__DEV__) { - warn( - `Failed setting prop "${key}" on <${this.tagName.toLowerCase()}>: ` + - `TypeError: Cannot set property tagName of # which has only a getter`, - ) - } - return - } if (val !== this._props[key]) { if (val === REMOVAL) { delete this._props[key]