Skip to content

yeonjuan/html-standard

Repository files navigation

html-standard

A TypeScript library for working with the HTML Living Standard specification.

⚠️ Experimental: This project may introduce breaking changes frequently.

Installation

npm install html-standard

Usage

Get Implicit ARIA Roles

import { element } from "html-standard";

// Basic elements
element("button").implicitRole(); // 'button'
element("nav").implicitRole(); // 'navigation'

// Attribute-dependent roles
element("a", {
  attributes: { get: (key) => (key === "href" ? "https://example.com" : null) },
}).implicitRole(); // 'link'

element("a").implicitRole(); // 'generic' (no href)

element("input", {
  attributes: { get: (key) => (key === "type" ? "checkbox" : null) },
}).implicitRole(); // 'checkbox'

Validate Attributes

import { element } from "html-standard";

const link = element("link");

// Validate 'rel' attribute
link.attributes.get("rel")?.validateValue("stylesheet"); // { valid: true, ... }
link.attributes.get("rel")?.validateValue("invalid-value"); // { valid: false, ... }

Features

  • Implicit ARIA roles per HTML-ARIA spec
  • Attribute validation based on HTML Standard
  • Case-insensitive element names
  • TypeScript support

License

MIT

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors