Fix CSS id for string prefixed with a digit

When encoding a string as a CSS identifier, we must add an underscore if
the strings starts with a digit.
This commit is contained in:
Francis Lachapelle
2014-03-06 21:32:36 -05:00
parent 28b1938bd9
commit 6cecca6c4f
4 changed files with 37 additions and 14 deletions

View File

@@ -106,6 +106,10 @@ String.prototype.asCSSIdentifier = function() {
newString = newString.replace(re, escapeds[i]);
}
if (/^\d+/.test(newString)) {
newString = '_' + newString;
}
return newString;
};