summaryrefslogtreecommitdiff
path: root/packages/webapi/src
diff options
context:
space:
mode:
authorGravatar Matthew Phillips <matthew@skypack.dev> 2022-04-13 08:44:22 -0400
committerGravatar GitHub <noreply@github.com> 2022-04-13 08:44:22 -0400
commit5acf77dd22be95e33ff838383a2c1790f484e380 (patch)
tree3ca2f5e2f49a05f0c3f1e834fb3ed40a7bc2f2a2 /packages/webapi/src
parent200a01c4f8a6d5685bfd063c294b6a6593bbad77 (diff)
downloadastro-5acf77dd22be95e33ff838383a2c1790f484e380.tar.gz
astro-5acf77dd22be95e33ff838383a2c1790f484e380.tar.zst
astro-5acf77dd22be95e33ff838383a2c1790f484e380.zip
Re-enable custom element test and fix "undefined" child (#3095)
* Re-enable custom element test and fix "undefined" child * Remove outdated comment * Adds a changeset
Diffstat (limited to 'packages/webapi/src')
-rw-r--r--packages/webapi/src/lib/CustomElementRegistry.ts5
-rw-r--r--packages/webapi/src/lib/Element.ts15
2 files changed, 20 insertions, 0 deletions
diff --git a/packages/webapi/src/lib/CustomElementRegistry.ts b/packages/webapi/src/lib/CustomElementRegistry.ts
index 3f7020087..3429e1e73 100644
--- a/packages/webapi/src/lib/CustomElementRegistry.ts
+++ b/packages/webapi/src/lib/CustomElementRegistry.ts
@@ -26,6 +26,11 @@ export class CustomElementRegistry {
if (!/-/.test(name))
throw new SyntaxError('Custom element name must contain a hyphen')
+ _.INTERNALS.set(constructor, {
+ attributes: {},
+ localName: name,
+ } as any)
+
internals.constructorByName.set(name, constructor)
internals.nameByConstructor.set(constructor, name)
diff --git a/packages/webapi/src/lib/Element.ts b/packages/webapi/src/lib/Element.ts
index 5827a0be0..1553f2863 100644
--- a/packages/webapi/src/lib/Element.ts
+++ b/packages/webapi/src/lib/Element.ts
@@ -1,6 +1,21 @@
import * as _ from './utils'
export class Element extends Node {
+ constructor() {
+ super();
+
+ if(_.INTERNALS.has(new.target)) {
+ const internals = _.internalsOf(new.target, 'Element', 'localName')
+ _.INTERNALS.set(this, {
+ attributes: {},
+ localName: internals.localName,
+ ownerDocument: this.ownerDocument,
+ shadowInit: null as unknown as ShadowRootInit,
+ shadowRoot: null as unknown as ShadowRoot,
+ } as ElementInternals)
+ }
+ }
+
hasAttribute(name: string): boolean {
void name