6
6
[ ![ Size] [ size-badge ]] [ size ]
7
7
8
8
Map of HTML elements to allowed attributes.
9
- Also contains global attributes under ` '*' ` .
10
- Includes attributes from HTML 4 and HTML (the WHATWG living standard).
11
9
12
- > ** Note** : Includes deprecated attributes.
13
- >
14
- > ** Note** : Attributes which were not global in HTML 4 but are in HTML, are only
15
- > included in the list of global attributes.
10
+ ## Contents
16
11
17
- ## Install
12
+ * [ What is this?] ( #what-is-this )
13
+ * [ When should I use this?] ( #when-should-i-use-this )
14
+ * [ Install] ( #install )
15
+ * [ Use] ( #use )
16
+ * [ API] ( #api )
17
+ * [ ` htmlElementAttributes ` ] ( #htmlelementattributes )
18
+ * [ Types] ( #types )
19
+ * [ Compatibility] ( #compatibility )
20
+ * [ Security] ( #security )
21
+ * [ Related] ( #related )
22
+ * [ Contribute] ( #contribute )
23
+ * [ License] ( #license )
24
+
25
+ ## What is this?
26
+
27
+ This is a map of tag names to lists of allowed attributes.
28
+ Global attributes are stored at the special tag name ` * ` .
29
+ All attributes from HTML 4 and the current living HTML spec are included.
30
+
31
+ > 👉 ** Note** : Includes deprecated attributes.
32
+
33
+ > 👉 ** Note** : Attributes which were not global in HTML 4 but are in HTML, are
34
+ > only included in the list of global attributes.
35
+
36
+ ## When should I use this?
18
37
19
- This package is ESM only: Node 12+ is needed to use it and it must be ` import ` ed
20
- instead of ` require ` d .
38
+ You can use this to figure out if certain attributes are allowed on certain
39
+ HTML elements .
21
40
22
- [ npm] [ ] :
41
+ ## Install
42
+
43
+ This package is [ ESM only] [ esm ] .
44
+ In Node.js (version 12.20+, 14.14+, or 16.0+), install with [ npm] [ ] :
23
45
24
46
``` sh
25
47
npm install html-element-attributes
26
48
```
27
49
50
+ In Deno with [ Skypack] [ ] :
51
+
52
+ ``` js
53
+ import {htmlElementAttributes } from ' https://cdn.skypack.dev/html-element-attributes@3?dts'
54
+ ```
55
+
56
+ In browsers with [ Skypack] [ ] :
57
+
58
+ ``` html
59
+ <script type =" module" >
60
+ import {htmlElementAttributes } from ' https://cdn.skypack.dev/html-element-attributes@3?min'
61
+ </script >
62
+ ```
63
+
28
64
## Use
29
65
30
66
``` js
@@ -58,28 +94,44 @@ There is no default export.
58
94
59
95
### ` htmlElementAttributes `
60
96
61
- ` Object.<string, string[]> ` — Map of lowercase tag names to an array of
62
- lowercase attribute names.
97
+ Map of lowercase HTML elements to allowed attributes
98
+ (` Record<string, Array<string>> ` ).
99
+
100
+ ## Types
101
+
102
+ This package is fully typed with [ TypeScript] [ ] .
103
+
104
+ ## Compatibility
63
105
64
- The object contains one special key: ` '*' ` , which contains global
65
- attributes that apply to all HTML elements.
106
+ This package is at least compatible with all maintained versions of Node.js.
107
+ As of now, that is Node.js 12.20+, 14.14+, and 16.0+.
108
+ It also works in Deno and modern browsers.
109
+
110
+ ## Security
111
+
112
+ This package is safe.
66
113
67
114
## Related
68
115
69
- * [ ` web-namespaces ` ] ( https://github.com/wooorm/web-namespaces )
70
- — List of web namespaces
71
- * [ ` html-tag-names ` ] ( https://github.com/wooorm/html-tag-names )
72
- — List of HTML tags
73
- * [ ` mathml-tag-names ` ] ( https://github.com/wooorm/mathml-tag-names )
74
- — List of MathML tags
75
- * [ ` svg-tag-names ` ] ( https://github.com/wooorm/svg-tag-names )
76
- — List of SVG tags
77
- * [ ` html-void-elements ` ] ( https://github.com/wooorm/html-void-elements )
78
- — List of void HTML tag-names
79
- * [ ` svg-element-attributes ` ] ( https://github.com/wooorm/svg-element-attributes )
80
- — Map of SVG elements to allowed attributes
81
- * [ ` aria-attributes ` ] ( https://github.com/wooorm/aria-attributes )
82
- — List of ARIA attributes
116
+ * [ ` wooorm/web-namespaces ` ] ( https://github.com/wooorm/web-namespaces )
117
+ — list of web namespaces
118
+ * [ ` wooorm/html-tag-names ` ] ( https://github.com/wooorm/html-tag-names )
119
+ — list of HTML tag names
120
+ * [ ` wooorm/mathml-tag-names ` ] ( https://github.com/wooorm/mathml-tag-names )
121
+ — list of MathML tag names
122
+ * [ ` wooorm/svg-tag-names ` ] ( https://github.com/wooorm/svg-tag-names )
123
+ — list of SVG tag names
124
+ * [ ` wooorm/html-void-elements ` ] ( https://github.com/wooorm/html-void-elements )
125
+ — list of void HTML tag names
126
+ * [ ` wooorm/svg-element-attributes ` ] ( https://github.com/wooorm/svg-element-attributes )
127
+ — map of SVG elements to attributes
128
+ * [ ` wooorm/aria-attributes ` ] ( https://github.com/wooorm/aria-attributes )
129
+ — list of ARIA attributes
130
+
131
+ ## Contribute
132
+
133
+ Yes please!
134
+ See [ How to Contribute to Open Source] [ contribute ] .
83
135
84
136
## License
85
137
@@ -105,6 +157,14 @@ attributes that apply to all HTML elements.
105
157
106
158
[ npm ] : https://docs.npmjs.com/cli/install
107
159
160
+ [ skypack ] : https://www.skypack.dev
161
+
108
162
[ license ] : license
109
163
110
164
[ author ] : https://wooorm.com
165
+
166
+ [ esm ] : https://gist.github.com/sindresorhus/a39789f98801d908bbc7ff3ecc99d99c
167
+
168
+ [ typescript ] : https://www.typescriptlang.org
169
+
170
+ [ contribute ] : https://opensource.guide/how-to-contribute/
0 commit comments