Skip to content

Commit

Permalink
Fix data-default-value not set for region if only 1 country
Browse files Browse the repository at this point in the history
  • Loading branch information
Nguyen Duc Chung committed Nov 15, 2019
1 parent 7de1761 commit 6bdb7c6
Show file tree
Hide file tree
Showing 6 changed files with 10 additions and 10 deletions.
6 changes: 3 additions & 3 deletions dist/crs.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion dist/crs.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/jquery.crs.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion dist/jquery.crs.min.js

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions source/source-crs.js
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@
};

// if the country dropdown has a default value, populate the region field as well
if (defaultSelectedValue !== null && countryElement.selectedIndex > 0) {
if (defaultSelectedValue !== null && countryElement.selectedIndex >= _showEmptyCountryOption) {
_populateRegionFields(countryElement, regionElement);

var defaultRegionSelectedValue = regionElement.getAttribute("data-default-value");
Expand Down Expand Up @@ -219,7 +219,7 @@

var weWantAndHaveShortCodes = displayType === 'shortcode' && regionData.hasShortcodes;
var indexToSort = weWantAndHaveShortCodes ? 1 : 0;
regionData.regions.sort(function(a, b) {
regionData.regions.sort(function (a, b) {
var x = a[indexToSort].toLowerCase();
var y = b[indexToSort].toLowerCase();
return x < y ? -1 : x > y ? 1 : 0;
Expand Down Expand Up @@ -276,7 +276,7 @@
}

// now prepend the preferred countries
for (var i=0; i<preferredShortCodes.length; i++) {
for (var i = 0; i < preferredShortCodes.length; i++) {
var code = preferredShortCodes[i];
updatedCountries.unshift(preferredMap[code]);
}
Expand Down
2 changes: 1 addition & 1 deletion source/source-jquery.crs.js
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@
});

// if the country dropdown has a default value, populate the region field as well
if (defaultSelectedValue && countryElement.selectedIndex > 0) {
if (defaultSelectedValue && countryElement.selectedIndex >= _showEmptyCountryOption) {
_populateRegionFields(countryElement, regionElement);

var defaultRegionSelectedValue = $(regionElement).attr("data-default-value");
Expand Down

0 comments on commit 6bdb7c6

Please sign in to comment.