Prototype: save a few lines in Element.Methods.hasClassName

This commit is contained in:
Thomas Fuchs 2007-06-17 22:14:07 +00:00
parent 1b8ef5af86
commit afbef44cd6

View File

@ -294,11 +294,8 @@ Element.Methods = {
hasClassName: function(element, className) {
if (!(element = $(element))) return;
var elementClassName = element.className;
if (elementClassName.length == 0) return false;
if (elementClassName == className ||
elementClassName.match(new RegExp("(^|\\s)" + className + "(\\s|$)")))
return true;
return false;
return (elementClassName.length > 0 && (elementClassName == className ||
elementClassName.match(new RegExp("(^|\\s)" + className + "(\\s|$)"))));
},
addClassName: function(element, className) {