From afbef44cd632873884763b34a3f636e0726ce4fb Mon Sep 17 00:00:00 2001 From: Thomas Fuchs Date: Sun, 17 Jun 2007 22:14:07 +0000 Subject: [PATCH] Prototype: save a few lines in Element.Methods.hasClassName --- src/dom.js | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/src/dom.js b/src/dom.js index 05ccefe..7a608b8 100644 --- a/src/dom.js +++ b/src/dom.js @@ -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) {