class A extends HTMLElement {
constructor() {
super()
return new Proxy(this, {})
}
}
window.customElements.define('a-element', A)Run Code Online (Sandbox Code Playgroud)
<a-element></a-element>Run Code Online (Sandbox Code Playgroud)
我如何代理自定义元素?
当我尝试它:
Uncaught InvalidStateError: custom element constructors must call super() first and must not return a different object.
我如何在script type =“ module”中获得ownerDocument?
<template>
text
</template>
<script type="module">
let owner = document.currentScript.ownerDocument // is null
// But i need get <template>
let tpl = owner.querySelector('template')
</script>Run Code Online (Sandbox Code Playgroud)