@kickscondor/umbrellajs
Version:
Lightweight and intuitive javascript library
15 lines (12 loc) • 474 B
JavaScript
// [INTERNAL USE ONLY]
// Handle attributes for the matched elements
u.prototype.attr = function (name, value, data) {
data = data ? 'data-' : '';
// This will handle those elements that can accept a pair with these footprints:
// .attr('a'), .attr('a', 'b'), .attr({ a: 'b' })
return this.pairs(name, value, function (node, name) {
return node.getAttribute(data + name);
}, function (node, name, value) {
node.setAttribute(data + name, value);
});
};