Awesome
svg-element-attributes
Map of SVG elements to allowed attributes.
Contents
- What is this?
- When should I use this?
- Install
- Use
- API
- Compatibility
- Security
- Related
- Contribute
- License
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*
), orxml:*
andxlink:*
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 16+), install with npm:
npm install svg-element-attributes
In Deno with esm.sh
:
import {svgElementAttributes} from 'https://esm.sh/svg-element-attributes@2'
In browsers with esm.sh
:
<script type="module">
import {svgElementAttributes} from 'https://esm.sh/svg-element-attributes@2?bundle'
</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 identifier
svgElementAttributes
.
There is no default export.
It exports no TypeScript types.
svgElementAttributes
Map of SVG elements to allowed attributes (Record<string, Array<string>>
).
Compatibility
This projects is compatible with maintained versions of Node.js.
When we cut a new major release,
we drop support for unmaintained versions of Node.
This means we try to keep the current release line,
svg-element-attributes@2
,
compatible with Node.js 12.
Security
This package is safe.
Related
wooorm/web-namespaces
ā list of web namespaceswooorm/html-tag-names
ā list of HTML tag nameswooorm/mathml-tag-names
ā list of MathML tag nameswooorm/svg-tag-names
ā list of SVG tag nameswooorm/html-void-elements
ā list of void HTML tag nameswooorm/html-element-attributes
ā map of HTML elements to attributeswooorm/aria-attributes
ā list of ARIA attributes
Contribute
Yes please! See How to Contribute to Open Source.
License
MIT Ā© Titus Wormer
<!-- Definition -->