svg-element-attributes
Map of SVG elements to allowed attributes.
Contents
What is this?
This is a map of tag names to lists of allowed attributes.
Global attributes are stored at the special tag name *
.
All attributes from SVG 1.1, SVG Tiny 1.2, and SVG 2 are
included.
👉 Note: Includes deprecated attributes.
👉 Note: ARIA (role
, aria-*
), event (ev:event
, on*
), or xml:*
and xlink:*
attributes are not included.
When should I use this?
You can use this to figure out if certain attributes are allowed on certain
SVG elements.
Install
This package is ESM only.
In Node.js (version 12.20+, 14.14+, or 16.0+), install with npm:
npm install svg-element-attributes
In Deno with Skypack:
import {svgElementAttributes} from 'https://cdn.skypack.dev/svg-element-attributes@2?dts'
In browsers with Skypack:
<script type="module">
import {svgElementAttributes} from 'https://cdn.skypack.dev/svg-element-attributes@2?min'
</script>
Use
import {svgElementAttributes} from 'svg-element-attributes'
console.log(svgElementAttributes['*'])
console.log(svgElementAttributes.circle)
Yields:
[
'about',
'class',
'content',
'datatype',
'id',
'lang',
'property',
'rel',
'resource',
'rev',
'tabindex',
'typeof' ]
[
'alignment-baseline',
'baseline-shift',
'clip',
'clip-path',
'clip-rule',
'transform',
'unicode-bidi',
'visibility',
'word-spacing',
'writing-mode' ]
API
This package exports the following identifiers: svgElementAttributes
.
There is no default export.
svgElementAttributes
Map of lowercase SVG elements to allowed attributes
(Record<string, Array<string>>
).
Types
This package is fully typed with TypeScript.
Compatibility
This package is at least compatible with all maintained versions of Node.js.
As of now, that is Node.js 12.20+, 14.14+, and 16.0+.
It also works in Deno and modern browsers.
Security
This package is safe.
Related
Contribute
Yes please!
See How to Contribute to Open Source.
License
MIT © Titus Wormer