UNPKG

attr-binder

Version:

Bind functions to attributes

15 lines (13 loc) 297 B
function bind(attr, x, y) { if (typeof x === 'function') { var node = document var fn = x } else { var node = x var fn = y } var nodes = node.querySelectorAll('[' + attr + ']') for(var i = 0; i < nodes.length; ++i) fn(nodes[i], nodes[i].getAttribute(attr)) } module.exports = bind