]> git.ipfire.org Git - thirdparty/vuejs/core.git/commitdiff
chore: update
authordaiwei <daiwei521@126.com>
Tue, 8 Oct 2024 11:57:38 +0000 (19:57 +0800)
committerdaiwei <daiwei521@126.com>
Tue, 8 Oct 2024 11:57:38 +0000 (19:57 +0800)
packages/runtime-dom/__tests__/customElement.spec.ts
packages/runtime-dom/src/apiCustomElement.ts

index 68e0f55a06eff5209b1c79aaf0155f3d84e17b23..9d2e14d3d73cdab403529b5129123f48a704844f 100644 (file)
@@ -1401,7 +1401,7 @@ describe('defineCustomElement', () => {
     customElements.define('el-attr-tag-name', E)
     container.innerHTML = '<el-attr-tag-name tag-name="foo">'
     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()
   })
 })
index a0a8a3a7c32b7798588bbd864e71078fc55de449..46238bdb001200a6e61e1f3e932a008bfc773a63 100644 (file)
@@ -451,13 +451,15 @@ export class VueElement
     }
 
     // defining getter/setters on prototype
+    const propValue: Record<string, any> = {}
     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 #<Element> which has only a getter`,
-        )
-      }
-      return
-    }
     if (val !== this._props[key]) {
       if (val === REMOVAL) {
         delete this._props[key]