diff --git a/src/lang/string.js b/src/lang/string.js index e141180..16935a7 100644 --- a/src/lang/string.js +++ b/src/lang/string.js @@ -311,17 +311,9 @@ Object.extend(String.prototype, (function() { * // -> 'MozBinding' **/ function camelize() { - var parts = this.split('-'), len = parts.length; - if (len == 1) return parts[0]; - - var camelized = this.charAt(0) == '-' - ? parts[0].charAt(0).toUpperCase() + parts[0].substring(1) - : parts[0]; - - for (var i = 1; i < len; i++) - camelized += parts[i].charAt(0).toUpperCase() + parts[i].substring(1); - - return camelized; + return this.replace(/-+(.)?/g, function(match, chr) { + return chr ? chr.toUpperCase() : ''; + }); } /**