plumatic / dommy

A tiny ClojureScript DOM manipulation and event library
760 stars 73 forks source link

Add attrs and data-attrs to get the attributes (or just the data attributes) on an element as a map. #104

Closed pdlug closed 2 years ago

pdlug commented 8 years ago

I added attrs and data-attrs to retrieve the attributes for an element as a map with keyword keys. data-attrs returns just the data attributes without the "data-" prefix. Seems like this would make an obvious addition to dommy, I didn't see any other way to easily retrieve all attributes for an element.

Usage:

<div id="myel" data-foo="bar" BIGKEY="BIGWORD" data-BIG="" lang="en"></div>
(attrs (sel1 [:#myel])) =>{:id "myel", :data-foo "bar", :bigkey "BIGWORD", :data-big nil, :lang "en"}
(data-attrs (sel1 [:#myel])) => {:foo "bar", :big nil}