From: edison Date: Thu, 17 Oct 2024 03:46:11 +0000 (+0800) Subject: Merge branch 'main' into edison/feat/ce_attachInternals X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=b8846bc4ec868cb4808c34bef53e533acccb5c38;p=thirdparty%2Fvuejs%2Fcore.git Merge branch 'main' into edison/feat/ce_attachInternals --- b8846bc4ec868cb4808c34bef53e533acccb5c38 diff --cc packages/runtime-dom/__tests__/customElement.spec.ts index cdfcd60215,6b9f7d1391..6f19ce08e8 --- a/packages/runtime-dom/__tests__/customElement.spec.ts +++ b/packages/runtime-dom/__tests__/customElement.spec.ts @@@ -1403,17 -1387,38 +1403,52 @@@ describe('defineCustomElement', () => expect(e.shadowRoot!.innerHTML).toBe(`false,boolean`) }) + test('support attachInternals method', () => { + const E = defineCustomElement({ + formAssociated: true, + render() { + return h('div', 'hello') + }, + }) + customElements.define('my-el-attach-internals', E) + container.innerHTML = `` + const e = container.childNodes[0] as VueElement + expect(e.shadowRoot!.innerHTML).toBe(`
hello
`) + expect(e._internals).toBeTruthy() + }) ++ + test('hyphenated attr removal', async () => { + const E = defineCustomElement({ + props: { + fooBar: { + type: Boolean, + }, + }, + render() { + return this.fooBar + }, + }) + customElements.define('el-hyphenated-attr-removal', E) + const toggle = ref(true) + const Comp = { + render() { + return h('el-hyphenated-attr-removal', { + 'foo-bar': toggle.value ? '' : null, + }) + }, + } + render(h(Comp), container) + const el = container.children[0] + expect(el.hasAttribute('foo-bar')).toBe(true) + expect((el as any).outerHTML).toBe( + ``, + ) + + toggle.value = false + await nextTick() + expect(el.hasAttribute('foo-bar')).toBe(false) + expect((el as any).outerHTML).toBe( + ``, + ) + }) })