dom-mapper
v0.0.6
Published
Small utility to map data attributes to JS objects
Downloads
2
Readme
Small utility to map data attributes to JS objects
Example:
Given the following HTML:
<div id="upload" data-item-count=4></div>
import * as DOM from 'dom-mapper';
// `UploadView` is a react view
// Any CSS supported by querySelectorAll is supported
var map: DOM.ElementMap = {
'#upload': UploadView,
};
DOM.iterateElementMap(map, (id: string, Klass: any, el: Element, props: any) => {
// props will be `{itemCount:4}` for #upload
ReactDom.render(<Klass {...props} />, el);
})
License
MIT