html-standard 0.0.6 → 0.0.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +56 -7
- package/dist/index.cjs +216 -2397
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +5 -69
- package/dist/index.d.ts +5 -69
- package/dist/index.js +215 -2402
- package/dist/index.js.map +1 -1
- package/package.json +8 -7
package/README.md
CHANGED
|
@@ -1,19 +1,68 @@
|
|
|
1
1
|
# html-standard
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
A TypeScript library that provides utilities for working with the HTML Living Standard specification.
|
|
4
|
+
|
|
5
|
+
> ⚠️ **Experimental**: This project is currently in an experimental stage and may introduce breaking changes frequently.
|
|
6
|
+
|
|
7
|
+
## Features
|
|
8
|
+
|
|
9
|
+
### `getImplicitRole`
|
|
10
|
+
|
|
11
|
+
Returns the implicit ARIA role of an HTML element according to the [HTML-ARIA specification](https://www.w3.org/TR/html-aria/). This provides the default role that each HTML element has.
|
|
12
|
+
|
|
13
|
+
```typescript
|
|
14
|
+
import { getImplicitRole } from "html-standard";
|
|
15
|
+
|
|
16
|
+
// Basic usage
|
|
17
|
+
getImplicitRole("button"); // 'button'
|
|
18
|
+
getImplicitRole("nav"); // 'navigation'
|
|
19
|
+
getImplicitRole("div"); // 'generic'
|
|
20
|
+
|
|
21
|
+
// Elements with attribute-dependent roles
|
|
22
|
+
getImplicitRole("a", {
|
|
23
|
+
attribute: (key) => (key === "href" ? "https://example.com" : null),
|
|
24
|
+
}); // 'link'
|
|
25
|
+
|
|
26
|
+
getImplicitRole("a", {
|
|
27
|
+
attribute: () => null,
|
|
28
|
+
}); // 'generic' (without href)
|
|
29
|
+
|
|
30
|
+
getImplicitRole("input", {
|
|
31
|
+
attribute: (key) => (key === "type" ? "checkbox" : null),
|
|
32
|
+
}); // 'checkbox'
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
**Key Features:**
|
|
36
|
+
|
|
37
|
+
- Implements implicit role mapping from the HTML Living Standard
|
|
38
|
+
- Supports attribute-dependent roles (e.g., `<a>`, `<input>`, `<img>`, `<select>`)
|
|
39
|
+
- Case-insensitive element name handling
|
|
4
40
|
|
|
5
41
|
## Installation
|
|
6
42
|
|
|
7
|
-
```
|
|
43
|
+
```bash
|
|
8
44
|
npm install html-standard
|
|
9
45
|
```
|
|
10
46
|
|
|
11
|
-
##
|
|
47
|
+
## Development
|
|
12
48
|
|
|
13
|
-
```
|
|
14
|
-
|
|
49
|
+
```bash
|
|
50
|
+
# Run tests
|
|
51
|
+
npm test
|
|
15
52
|
|
|
16
|
-
|
|
53
|
+
# Run tests in watch mode
|
|
54
|
+
npm run test:watch
|
|
17
55
|
|
|
18
|
-
|
|
56
|
+
# Run tests with UI
|
|
57
|
+
npm run test:ui
|
|
58
|
+
|
|
59
|
+
# Type check
|
|
60
|
+
npm run ts
|
|
61
|
+
|
|
62
|
+
# Build
|
|
63
|
+
npm run build
|
|
19
64
|
```
|
|
65
|
+
|
|
66
|
+
## License
|
|
67
|
+
|
|
68
|
+
MIT
|