Just a reality check before I refactor this code. It comes from someone who is otherwise competent, as far as I can tell. Here is a sample:
// remove line at the latest list
if($(".extra-space").length > 0) {
$(".extra-space li:last").addClass("noborder");
}
// select all
if($(".extra-select-all").length > 0) {
$(".extra-select-all").click(function() {
if($(this).attr("checked") == true) $(".extra-select-item").attr("checked","checked");
else $(".extra-select-item").removeAttr("checked");
});
}
Does anyone know a rationale behind this pattern, or is it just ignorance that the if wrappers are needless?
// remove line at the latest list
$(".extra-space li:last").addClass("noborder");
// select all
$(".extra-select-all").click(function() {
if($(this).attr("checked") == true) $(".extra-select-item").attr("checked","checked");
else $(".extra-select-item").removeAttr("checked");
});
I’d say you are right. No need for the checks.