Skip to content

Commit c508b43

Browse files
authored
Allow numbers in to dash (#184)
* Changing the conditions of replacement in toDash If string from customClass prefix ends with a number does not work replacement regexp. For example "classname2" -> classname2wrapper instead of classname2-wrapper * add missing test case
1 parent 0a9755a commit c508b43

File tree

2 files changed

+10
-1
lines changed

2 files changed

+10
-1
lines changed

src/jquery.selectric.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,7 @@
170170
* @return {string} The string transformed to dash-case.
171171
*/
172172
toDash: function(str) {
173-
return str.replace(/([a-z])([A-Z])/g, '$1-$2').toLowerCase();
173+
return str.replace(/([a-z0-9])([A-Z])/g, '$1-$2').toLowerCase();
174174
},
175175

176176
/**

test/basic.spec.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -205,6 +205,15 @@ describe('basic suite', function() {
205205
expect($('.custom-wrapper').length).toBe(1);
206206
});
207207

208+
it('should change classes even if last char is a number', function() {
209+
select.selectric({
210+
customClass: {
211+
prefix: 'custom2'
212+
}
213+
});
214+
expect($('.custom2-wrapper').length).toBe(1);
215+
});
216+
208217
it('should change classes to camelcase', function() {
209218
select.selectric({
210219
customClass: {

0 commit comments

Comments
 (0)