From c43ea73f7f0622441dc13cbee067ecbb1114c5b9 Mon Sep 17 00:00:00 2001 From: jlukic Date: Tue, 18 Aug 2015 12:19:01 -0400 Subject: [PATCH] Deal with type casting in a consistent way --- RELEASE-NOTES.md | 1 + src/definitions/modules/dropdown.js | 17 +++++++++-------- 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/RELEASE-NOTES.md b/RELEASE-NOTES.md index 6a5dead9c..4aec95abf 100644 --- a/RELEASE-NOTES.md +++ b/RELEASE-NOTES.md @@ -88,6 +88,7 @@ - **Build Tools** - Fixes issue on `win` platform where packaged theme would not correctly update when using watch due to regExp not matching windows path separators. - **Dropdown** - Dropdown will no longer fire native `onchange` event on hidden input when setting value during initial load (unless `fireOnInit: true`) #2795 **Thanks @lauri-elevant** - **Dropdown** - Fixed issue where `forceSelection` would not occur when `pageLostFocus` (clicked into another tab and back) +- **Dropdown** - Fixed issue where using the specific value `value="false"` would cause an option to not be removable from a multiple select - **Dropdown/Tab** - Fixed an instance where `metadata` was not referencing settings metadata value - **Form Validation** - Fixed issue with `get value(s)` where unchecked checkboxes would not correctly retrieve values - **Input** `action input` and `labeled input` now have focused border on inner edge with label/button diff --git a/src/definitions/modules/dropdown.js b/src/definitions/modules/dropdown.js index 010753b4d..4570d998e 100644 --- a/src/definitions/modules/dropdown.js +++ b/src/definitions/modules/dropdown.js @@ -1562,10 +1562,10 @@ $.fn.dropdown = function(parameters) { return false; } return ($choice.data(metadata.value) !== undefined) - ? $choice.data(metadata.value) + ? String( $choice.data(metadata.value) ) : (typeof choiceText === 'string') ? $.trim(choiceText.toLowerCase()) - : choiceText + : String(choiceText) ; }, inputEvent: function() { @@ -1688,7 +1688,7 @@ $.fn.dropdown = function(parameters) { return; } if(isMultiple) { - if($.inArray(optionValue.toString(), value) !== -1 || $.inArray(optionText, value) !== -1) { + if($.inArray( String(optionValue), value) !== -1 || $.inArray(optionText, value) !== -1) { $selectedItem = ($selectedItem) ? $selectedItem.add($choice) : $choice @@ -1703,7 +1703,7 @@ $.fn.dropdown = function(parameters) { } } else { - if( optionValue.toString() == value.toString() || optionText == value) { + if( String(optionValue) == String(value) || optionText == value) { module.verbose('Found select item by value', optionValue, value); $selectedItem = $choice; return true; @@ -2143,8 +2143,8 @@ $.fn.dropdown = function(parameters) { hasInput = ($input.length > 0), isAddition = !module.has.value(value), currentValue = module.get.values(), - stringValue = (typeof value == 'number') - ? value.toString() + stringValue = (value !== undefined) + ? String(value) : value, newValue ; @@ -2544,6 +2544,7 @@ $.fn.dropdown = function(parameters) { ; if(module.is.multiple()) { if(settings.useLabels) { + console.log(selectedValue); module.remove.value(selectedValue, selectedText, $selected); module.remove.label(selectedValue); } @@ -2622,8 +2623,8 @@ $.fn.dropdown = function(parameters) { .each(function(){ var value = $(this).data(metadata.value), - stringValue = (typeof value == 'number') - ? value.toString() + stringValue = (value !== undefined) + ? String(value) : value, isUserValue = module.is.userValue(stringValue) ;