await nextTick()
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 = `<my-el-attach-internals></my-el-attach-internals>`
+ const e = container.childNodes[0] as VueElement
+ expect(e.shadowRoot!.innerHTML).toBe(`<div>hello</div>`)
+ expect(e._internals).toBeTruthy()
+ })
})
if (isPlainObject(Comp)) extend(Comp, extraOptions)
class VueCustomElement extends VueElement {
static def = Comp
+ static formAssociated = !!options.formAssociated
+
constructor(initialProps?: Record<string, any>) {
super(Comp, initialProps, _createApp)
}
implements ComponentCustomElementInterface
{
_isVueCE = true
+ _internals: ElementInternals | null = null
/**
* @internal
*/
private _createApp: CreateAppFunction<Element> = createApp,
) {
super()
+
+ if (this.attachInternals) this._internals = this.attachInternals()
+
if (this.shadowRoot && _createApp !== createApp) {
this._root = this.shadowRoot
} else {