From e6c59672ac98db6d5e7b2de6e66435d740cad0da Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=BCrg=20Lehni?= Date: Sat, 10 Nov 2012 22:24:50 -0800 Subject: [PATCH] Update camelize() and hyphenate() to simpler versions. --- src/core/Base.js | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/src/core/Base.js b/src/core/Base.js index 0cc911c4..8c6a6230 100644 --- a/src/core/Base.js +++ b/src/core/Base.js @@ -221,7 +221,7 @@ this.Base = Base.inject(/** @lends Base# */{ * Camelizes the passed hyphenated string: caps-lock -> capsLock */ camelize: function(str) { - return str.replace(/-(\w)/g, function(all, chr) { + return str.replace(/-(.)/g, function(all, chr) { return chr.toUpperCase(); }); }, @@ -230,11 +230,7 @@ this.Base = Base.inject(/** @lends Base# */{ * Converst camelized strings to hyphenated ones: CapsLock -> caps-lock */ hyphenate: function(str) { - return str.replace(/[a-z][A-Z0-9]|[0-9][a-zA-Z]|[A-Z]{2}[a-z]/g, - function(match) { - return match.charAt(0) + '-' + match.substring(1); - } - ).toLowerCase(); + return str.replace(/([a-z])([A-Z])/g, '$1-$2').toLowerCase(); }, /**