Skip to content

Commit b1495d1

Browse files
committed
Update docs
1 parent 81bd2fe commit b1495d1

File tree

1 file changed

+91
-11
lines changed

1 file changed

+91
-11
lines changed

readme.md

Lines changed: 91 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -6,24 +6,62 @@
66
[![Size][size-badge]][size]
77

88
Map of SVG elements to allowed attributes.
9-
Also contains global attributes under `'*'`.
109

11-
Includes attributes from [SVG 1.1][1.1], [SVG Tiny 1.2][1.2], and [SVG 2][2.0].
10+
## Contents
1211

13-
> **Note**: Does not include ARIA attributes (`role`, `aria-*`), `xml:*` or
14-
> `xlink:*` attributes, event attributes (`on*`), or `ev:event`.
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+
* [`svgElementAttributes`](#svgelementattributes)
18+
* [Types](#types)
19+
* [Compatibility](#compatibility)
20+
* [Security](#security)
21+
* [Related](#related)
22+
* [Contribute](#contribute)
23+
* [License](#license)
1524

16-
## Install
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 [SVG 1.1][1.1], [SVG Tiny 1.2][1.2], and [SVG 2][2.0] are
30+
included.
31+
32+
> 👉 **Note**: Includes deprecated attributes.
33+
34+
> 👉 **Note**: ARIA (`role`, `aria-*`), event (`ev:event`, `on*`), or `xml:*`
35+
> and `xlink:*` attributes are not included.
1736
18-
This package is [ESM only](https://gist.github.com/sindresorhus/a39789f98801d908bbc7ff3ecc99d99c):
19-
Node 12+ is needed to use it and it must be `import`ed instead of `require`d.
37+
## When should I use this?
38+
39+
You can use this to figure out if certain attributes are allowed on certain
40+
SVG elements.
41+
42+
## Install
2043

21-
[npm][]:
44+
This package is [ESM only][esm].
45+
In Node.js (version 12.20+, 14.14+, or 16.0+), install with [npm][]:
2246

2347
```sh
2448
npm install svg-element-attributes
2549
```
2650

51+
In Deno with [Skypack][]:
52+
53+
```js
54+
import {svgElementAttributes} from 'https://cdn.skypack.dev/svg-element-attributes@2?dts'
55+
```
56+
57+
In browsers with [Skypack][]:
58+
59+
```html
60+
<script type="module">
61+
import {svgElementAttributes} from 'https://cdn.skypack.dev/svg-element-attributes@2?min'
62+
</script>
63+
```
64+
2765
## Use
2866

2967
```js
@@ -70,10 +108,44 @@ There is no default export.
70108

71109
### `svgElementAttributes`
72110

73-
`Object.<Array.<string>>` — Map of tag names to an array of attribute names.
111+
Map of lowercase SVG elements to allowed attributes
112+
(`Record<string, Array<string>>`).
74113

75-
The object contains one special key: `'*'`, which contains global attributes
76-
that apply to all SVG elements.
114+
## Types
115+
116+
This package is fully typed with [TypeScript][].
117+
118+
## Compatibility
119+
120+
This package is at least compatible with all maintained versions of Node.js.
121+
As of now, that is Node.js 12.20+, 14.14+, and 16.0+.
122+
It also works in Deno and modern browsers.
123+
124+
## Security
125+
126+
This package is safe.
127+
128+
## Related
129+
130+
* [`wooorm/web-namespaces`](https://github.com/wooorm/web-namespaces)
131+
— list of web namespaces
132+
* [`wooorm/html-tag-names`](https://github.com/wooorm/html-tag-names)
133+
— list of HTML tag names
134+
* [`wooorm/mathml-tag-names`](https://github.com/wooorm/mathml-tag-names)
135+
— list of MathML tag names
136+
* [`wooorm/svg-tag-names`](https://github.com/wooorm/svg-tag-names)
137+
— list of SVG tag names
138+
* [`wooorm/html-void-elements`](https://github.com/wooorm/html-void-elements)
139+
— list of void HTML tag names
140+
* [`wooorm/html-element-attributes`](https://github.com/wooorm/html-element-attributes)
141+
— map of HTML elements to attributes
142+
* [`wooorm/aria-attributes`](https://github.com/wooorm/aria-attributes)
143+
— list of ARIA attributes
144+
145+
## Contribute
146+
147+
Yes please!
148+
See [How to Contribute to Open Source][contribute].
77149

78150
## License
79151

@@ -99,10 +171,18 @@ that apply to all SVG elements.
99171

100172
[npm]: https://docs.npmjs.com/cli/install
101173

174+
[skypack]: https://www.skypack.dev
175+
102176
[license]: license
103177

104178
[author]: https://wooorm.com
105179

180+
[esm]: https://gist.github.com/sindresorhus/a39789f98801d908bbc7ff3ecc99d99c
181+
182+
[typescript]: https://www.typescriptlang.org
183+
184+
[contribute]: https://opensource.guide/how-to-contribute/
185+
106186
[1.1]: https://www.w3.org/TR/SVG/attindex.html
107187

108188
[1.2]: https://www.w3.org/TR/SVGTiny12/attributeTable.html

0 commit comments

Comments
 (0)