0.0.1 • Published 8 years ago

get-attrs v0.0.1

Weekly downloads
2
License
MIT
Repository
github
Last release
8 years ago

Get Attributes

Get all attributes from a DOM element.

Install

npm install get-attrs

Usage

Doing this:

const getAttrs = require('get-attrs')

const el = document.querySelector('svg')
const attrs = getAttrs(el)

console.log(attrs)

with this:

<svg xmlns="http://www.w3.org/2000/svg" width="256" height="312" viewBox="0 0 256 312"
     id="myId" data-float="1.234" onload="startAnimation('fast')" unquoted=d/\nger!></svg>
  ...
</svg>

makes this:

{
  xmlns: "http://www.w3.org/2000/svg",
  width: 256,
  height: 312,
  viewBox: "0 0 256 312",
  id: "myId",
  data-float: 1.234,
  onload: "startAnimation('fast')",
  unquoted: "d/\nger!"
}