-
Notifications
You must be signed in to change notification settings - Fork 49
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add support for setting attributes with an object #53
base: master
Are you sure you want to change the base?
Conversation
Not entirely sure I should be doing all this as one single pull request. Happy to break this apart if needed :) |
Added some spaces to the |
good idea! i'd probably do it with the object check as the very first thing to exit early. also no need for the arguments length or own property checks with for the object i think List.prototype.attr = function(name, val){
// object
if ('object' == typeof name) {
for (var attr in obj) this.attr(attr, name[attr]);
return this;
}
// get
if (1 == arguments.length) {
return this.els[0] && this.els[0].getAttribute(name);
}
// remove
if (null == val) {
return this.removeAttr(name);
}
// set
return this.forEach(function(el){
el.setAttribute(name, val);
});
}; also single quotes |
+1 |
lgtm :) |
+1 |
please rebase and we'll merge :-) |
Changes: