You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I would suggest to have two APIs for that purpose.
$.setProps.sAttr = function(o) {
for (var attribute in o) {
let v = o[attribute]
switch (v) {
case null:
break;
case false:
this.removeAttribute(attribute);
break;
case true:
v = "";
default:
this.setAttribute(attribute, v);
}
}
};
$.setProps.sClass = function(o) {
for (var c in o) {
switch (o[c]) {
case true:
this.classList.add(c);
break;
case false:
this.classList.remove(c);
break;
}
}
};
$.add({
'sAttr': $.setProps.sAttr,
'sClass': $.setProps.sClass
});
In the current version, it is hard to add/remove attribute and className using Bliss's functions
one common use in jQuery is
In the current bliss,
If you do that operation with other
setProps
, it would be so ugly.I would suggest to have two APIs for that purpose.
then the code become much better.
Remarks:
.attributes()
can be merged with.sAttr()
.toggleAttribute()
can be removed as.sClass()
is more powerful and consistence with yoursetProps
design.The text was updated successfully, but these errors were encountered: