From b26cff34687d970970e00643912b9eba8f6fbfbe Mon Sep 17 00:00:00 2001 From: Buddy Date: Fri, 6 Nov 2026 21:31:14 -0800 Subject: [PATCH] Support [selector, Class] refs and show resolved types for refs, observedAttributes, and attributeFor --- README.md | 9 ++++-- oxlint.config.ts | 2 ++ src/index.ts | 3 ++ src/types.ts | 62 +++++++++++++++++++++++++++++--------- src/web-component.ts | 38 ++++++++++++++++++----- test/types.test-d.ts | 26 ++++++++++++++++ test/web-component.test.ts | 13 ++++++++ 7 files changed, 129 insertions(+), 24 deletions(-) diff --git a/README.md b/README.md index 34e3820..df71028 100644 --- a/README.md +++ b/README.md @@ -10,8 +10,12 @@ const SPEC = { template: '', css: ':host { display: block; }', events: ['click'], - element: { input: 'input.name' }, // refs.input: HTMLInputElement | null - elements: { buttons: 'button' }, // refs.buttons: HTMLButtonElement[] + element: { + input: 'input.name', // refs.input: HTMLInputElement | null (from the tag) + thing: '.thing', // refs.thing: Element | null (no tag to go on) + card: ['.card', HTMLElement], // refs.card: HTMLElement | null (checked with instanceof) + }, + elements: { buttons: 'button' }, // refs.buttons: HTMLButtonElement[] props: { userId: number(), // user-id number | undefined min: number({ default: 1 }), // min number @@ -41,6 +45,7 @@ ExampleElement.observedAttributes; // readonly ('user-id' | 'min' | 'is-ready' | - **Codecs**: `string`, `number`, `enable`, `disable`, `choice([...])`, `json()`, `prop({ default, decode, encode })`. - **Shadow DOM**: `shadow` attaches a root and clones `template` into it; `css` is a shared adopted stylesheet. An existing declarative shadow root is used instead (and `shadow`/`template` are ignored). `root` is the shadow root (even when closed) or the element itself. - **Light DOM**: `template` is appended on first connect; `css` is added once per element type, as a `