html-standard
v0.0.13
Published
A TypeScript library for working with the HTML Living Standard specification.
Readme
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-standardUsage
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
