Skip to content

Commit

Permalink
fix(StrictARIA): Fixed the types finally, my brain doesnt work right …
Browse files Browse the repository at this point in the history
…again
  • Loading branch information
DeepDoge committed Nov 7, 2024
1 parent 8e7c543 commit e3a9930
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 7 deletions.
9 changes: 5 additions & 4 deletions lib/aria.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,21 +13,22 @@ export namespace StrictARIA {
* properties of specific element types.
*/
export type Attributes = {
[K in keyof Properties as K extends `aria${infer Name}` ?
[K in keyof Properties.Mixin as K extends `aria${infer Name}` ?
Name extends `${infer Name}Elements` ?
`aria-${Lowercase<Name>}`
: `aria-${Lowercase<Name>}`
: never]: Element[] extends Properties[K] ? string | null : Properties[K]
: never]: Element[] extends Properties.Mixin[K] ? string | null : Properties.Mixin[K]
}

/**
* Interface representing all ARIA properties, including those that override base properties and
* experimental attributes that are supported by specific browsers.
*/
export type Properties = Omit<ARIAMixin, keyof PropertiesStrict> & PropertiesStrict
type PropertiesStrict = Properties.Override & Properties.Experimental
export type Properties = Properties.Override & Properties.Experimental

export namespace Properties {
export type Mixin = Omit<ARIAMixin, keyof Properties> & Properties

/**
* Experimental ARIA properties that may not be fully standardized or cross-browser.
*/
Expand Down
6 changes: 3 additions & 3 deletions lib/tags.ts
Original file line number Diff line number Diff line change
Expand Up @@ -298,9 +298,9 @@ type IsReadonly<T, K extends keyof T> =
true
: false

export type WithLifecycle<T extends HTMLElement> = T & HTMLElementWithLifecycle
type HTMLElementWithStrictARIA = Omit<HTMLElement, keyof StrictARIA.Properties> &
StrictARIA.Properties
export type WithLifecycle<T extends HTMLElement> = Omit<T, keyof StrictARIA.Properties> & HTMLElementWithLifecycle
type HTMLElementWithStrictARIA = Omit<HTMLElement, keyof StrictARIA.Properties> & StrictARIA.Properties

interface HTMLElementWithLifecycle extends HTMLElementWithStrictARIA {
effect(callback: Lifecycle.OnConnected<this>): Lifecycle.OffConnected
}
Expand Down

0 comments on commit e3a9930

Please sign in to comment.