clean up unnecessarily complicated code in camelize() -- all tests pass ff & ie6
git-svn-id: http://svn.openlayers.org/trunk/openlayers@3806 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
This commit is contained in:
@@ -97,19 +97,11 @@ String.indexOf = function(object) {
|
|||||||
*/
|
*/
|
||||||
String.prototype.camelize = function() {
|
String.prototype.camelize = function() {
|
||||||
var oStringList = this.split('-');
|
var oStringList = this.split('-');
|
||||||
if (oStringList.length == 1) {
|
var camelizedString = oStringList[0];
|
||||||
return oStringList[0];
|
for (var i = 1; i < oStringList.length; i++) {
|
||||||
}
|
|
||||||
|
|
||||||
var camelizedString = (this.indexOf('-') == 0)
|
|
||||||
? oStringList[0].charAt(0).toUpperCase() + oStringList[0].substring(1)
|
|
||||||
: oStringList[0];
|
|
||||||
|
|
||||||
for (var i = 1, len = oStringList.length; i < len; i++) {
|
|
||||||
var s = oStringList[i];
|
var s = oStringList[i];
|
||||||
camelizedString += s.charAt(0).toUpperCase() + s.substring(1);
|
camelizedString += s.charAt(0).toUpperCase() + s.substring(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
return camelizedString;
|
return camelizedString;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user