Skip to content

Commit 2cbffd9

Browse files
authored
Fix empty label (145) (#150)
fix issue 145
1 parent d023297 commit 2cbffd9

File tree

5 files changed

+16
-5
lines changed

5 files changed

+16
-5
lines changed

public/jquery.selectric.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
* /,'
1010
* /'
1111
*
12-
* Selectric ϟ v1.11.0 (Oct 06 2016) - http://lcdsantos.github.io/jQuery-Selectric/
12+
* Selectric ϟ v1.11.0 (Nov 20 2016) - http://lcdsantos.github.io/jQuery-Selectric/
1313
*
1414
* Copyright (c) 2016 Leonardo Santos; MIT License
1515
*
@@ -371,7 +371,7 @@
371371
// Hide default (please choose) if more then one element were selected.
372372
// If no option value were given value is set to option text by default
373373
if ( labelMarkup.length > 1 || labelMarkup.length === 0 ) {
374-
return $.trim(item.value) !== '' && item.value !== item.text;
374+
return $.trim(item.value) !== '';
375375
}
376376
return item;
377377
});

public/jquery.selectric.min.js

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/jquery.selectric.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -354,7 +354,7 @@
354354
// Hide default (please choose) if more then one element were selected.
355355
// If no option value were given value is set to option text by default
356356
if ( labelMarkup.length > 1 || labelMarkup.length === 0 ) {
357-
return $.trim(item.value) !== '' && item.value !== item.text;
357+
return $.trim(item.value) !== '';
358358
}
359359
return item;
360360
});

test/fixtures/multiple.html

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,6 @@
44
<option value="cat">Cat</option>
55
<option value="dog">Dog</option>
66
<option value="chicken">Chicken</option>
7+
<option value="losabim oxigenium">Losabim Oxigenium</option>
8+
<option value="Dagobert Duck">Dagobert Duck</option>
79
</select>

test/multiple.spec.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,15 @@ describe('multiple selects', function() {
128128
$('.selectric').click();
129129
expect($('.selectric-wrapper').find('.label').text()).toBe('Ant, Cat, Dog');
130130
});
131+
132+
it('should build the label correctly by ignoring case or whitespace', function() {
133+
var listItems = $('.selectric-items');
134+
$('.selectric').click();
135+
listItems.find('li').eq(5).click();
136+
listItems.find('li').eq(6).click();
137+
$('.selectric').click();
138+
expect($('.selectric-wrapper').find('.label').text()).toBe('Losabim Oxigenium, Dagobert Duck');
139+
});
131140
});
132141

133142
});

0 commit comments

Comments
 (0)