0.0.7 • Published 7 months ago

html-info v0.0.7

Weekly downloads
-
License
MIT
Repository
github
Last release
7 months ago

html-info

Reasonably-complete JSON data and TypeScript definitions for HTML and ARIA attributes, continously scraped directly from the specs.

Sources

Usage

import {
  ElementType,
  ElementToAttributes,
  SVGNamespace,
  HTMLTagToEventMap,
  HTMLTagToAttributes,
  SVGTagToAttributes
} from 'html-info'

type HTMLButtonElement_ = ElementType<'button'> // HTMLButtonElement

type DivAttributes = ElementToAttributes<'div'> // HTMLGlobalAttributes & specific div attributes

// SVG and MathML attributes not yet implemented
type PathAttributes = ElementToAttributes<'path', SVGNamespace> // SVGGlobalAttributes & specific path attributes

type DivAttributes2 = HTMLTagToAttributes['div'] // same as ElementToAttributes<'div'>

type PathAttributes2 = SVGTagToEventMap['path'] // same as ElementToAttributes<'path', SVGNamespace>

type VideoEvents = HTMLTagToEventMap['video'] // HTMLVideoElementEventMap

Extending

class HTMLMyCustomElement extends HTMLElement {
  constructor() {
    super()
  }
}

customElements.define("my-custom", HTMLMyCustomElement)

declare global {
  interface HTMLElementTagNameMap {
    "my-custom": HTMLMyCustomElement
  }
}

// Events

interface HTMLMyCustomElementEventMap extends HTMLElementEventMap {
  bruhmoment: CustomEvent<{ bruh: string }>
}

declare module "html-info" {
  interface HTMLTagToEventMap {
    "my-custom": HTMLMyCustomElementEventMap
  }
}

// Attributes

declare module "html-info" {
  interface HTMLTagToAttributes {
    "my-custom": {
      "allow-bruh-moments": "" | "true" | "bet"
    }
  }
}
0.0.7

7 months ago

0.0.6

7 months ago

0.0.3

2 years ago

0.0.5

2 years ago

0.0.4

2 years ago

0.0.2

2 years ago

0.0.1

2 years ago