intl-tel-input 18.0.2 → 18.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (34) hide show
  1. package/README.md +20 -15
  2. package/build/css/intlTelInput.css +1 -1
  3. package/build/js/data.js +1 -1
  4. package/build/js/data.min.js +1 -1
  5. package/build/js/intlTelInput-jquery.js +58 -35
  6. package/build/js/intlTelInput-jquery.min.js +3 -3
  7. package/build/js/intlTelInput.js +58 -35
  8. package/build/js/intlTelInput.min.js +3 -3
  9. package/composer.json +1 -1
  10. package/demo.html +4 -3
  11. package/examples/gen/country-sync.html +6 -6
  12. package/examples/gen/default-country-ip.html +7 -7
  13. package/examples/gen/display-number.html +5 -5
  14. package/examples/gen/hidden-input.html +5 -5
  15. package/examples/gen/init-promise.html +5 -5
  16. package/examples/gen/is-valid-number.html +6 -6
  17. package/examples/gen/js/countrySync.js +1 -1
  18. package/examples/gen/js/defaultCountryIp.js +3 -3
  19. package/examples/gen/js/displayNumber.js +1 -1
  20. package/examples/gen/js/hiddenInput.js +1 -1
  21. package/examples/gen/js/initPromise.js +1 -1
  22. package/examples/gen/js/isValidNumber.js +1 -1
  23. package/examples/gen/js/modifyCountryData.js +1 -1
  24. package/examples/gen/js/multipleInstances.js +2 -2
  25. package/examples/gen/js/nationalMode.js +1 -1
  26. package/examples/gen/js/onlyCountriesEurope.js +1 -1
  27. package/examples/gen/modify-country-data.html +5 -5
  28. package/examples/gen/multiple-instances.html +6 -6
  29. package/examples/gen/national-mode.html +5 -5
  30. package/examples/gen/only-countries-europe.html +5 -5
  31. package/examples/js/defaultCountryIp.js.ejs +2 -2
  32. package/package.json +1 -1
  33. package/src/css/intlTelInput.scss +1 -1
  34. package/src/js/intlTelInput.js +64 -30
@@ -4,10 +4,10 @@
4
4
  <meta charset="utf-8">
5
5
  <title>Example: Validation</title>
6
6
  <link rel="stylesheet" href="../css/prism.css">
7
- <link rel="stylesheet" href="../../build/css/intlTelInput.css?1680992740399">
8
- <link rel="stylesheet" href="../../build/css/demo.css?1680992740399">
7
+ <link rel="stylesheet" href="../../build/css/intlTelInput.css?1680993492797">
8
+ <link rel="stylesheet" href="../../build/css/demo.css?1680993492797">
9
9
 
10
- <link rel="stylesheet" href="../css/isValidNumber.css?1680992740399">
10
+ <link rel="stylesheet" href="../css/isValidNumber.css?1680993492797">
11
11
 
12
12
 
13
13
  <!-- Global site tag (gtag.js) - Google Analytics -->
@@ -41,7 +41,7 @@ var errorMap = [&quot;Invalid number&quot;, &quot;Invalid country code&quot;, &q
41
41
 
42
42
  // initialise plugin
43
43
  var iti = window.intlTelInput(input, {
44
- utilsScript: &quot;../../build/js/utils.js?1680992740399&quot;
44
+ utilsScript: &quot;../../build/js/utils.js?1680993492797&quot;
45
45
  });
46
46
 
47
47
  var reset = function() {
@@ -80,7 +80,7 @@ input.addEventListener(&#39;keyup&#39;, reset);
80
80
  </div>
81
81
 
82
82
  <script src="../js/prism.js"></script>
83
- <script src="../../build/js/intlTelInput.js?1680992740399"></script>
84
- <script src="./js/isValidNumber.js?1680992740399"></script>
83
+ <script src="../../build/js/intlTelInput.js?1680993492797"></script>
84
+ <script src="./js/isValidNumber.js?1680993492797"></script>
85
85
  </body>
86
86
  </html>
@@ -5,7 +5,7 @@ var countryData = window.intlTelInputGlobals.getCountryData(),
5
5
 
6
6
  // init plugin
7
7
  var iti = window.intlTelInput(input, {
8
- utilsScript: "../../build/js/utils.js?1680992740399" // just for formatting/placeholders etc
8
+ utilsScript: "../../build/js/utils.js?1680993492797" // just for formatting/placeholders etc
9
9
  });
10
10
 
11
11
  // populate the country dropdown
@@ -2,10 +2,10 @@ var input = document.querySelector("#phone");
2
2
  window.intlTelInput(input, {
3
3
  initialCountry: "auto",
4
4
  geoIpLookup: function(callback) {
5
- fetch("http://ip-api.com/json")
5
+ fetch("https://ipapi.co/json")
6
6
  .then(function(res) { return res.json(); })
7
- .then(function(data) { callback(data.countryCode); })
7
+ .then(function(data) { callback(data.country_code); })
8
8
  .catch(function() { callback("us"); });
9
9
  },
10
- utilsScript: "../../build/js/utils.js?1680992740399" // just for formatting/placeholders etc
10
+ utilsScript: "../../build/js/utils.js?1680993492797" // just for formatting/placeholders etc
11
11
  });
@@ -1,4 +1,4 @@
1
1
  var input = document.querySelector("#phone");
2
2
  window.intlTelInput(input, {
3
- utilsScript: "../../build/js/utils.js?1680992740399" // just for formatting/placeholders etc
3
+ utilsScript: "../../build/js/utils.js?1680993492797" // just for formatting/placeholders etc
4
4
  });
@@ -1,5 +1,5 @@
1
1
  var input = document.querySelector("#phone");
2
2
  window.intlTelInput(input, {
3
3
  hiddenInput: "full_phone",
4
- utilsScript: "../../build/js/utils.js?1680992740399" // just for formatting/placeholders etc
4
+ utilsScript: "../../build/js/utils.js?1680993492797" // just for formatting/placeholders etc
5
5
  });
@@ -2,7 +2,7 @@ var input = document.querySelector("#phone");
2
2
  var statusElement = document.querySelector("#status");
3
3
 
4
4
  var iti = window.intlTelInput(input, {
5
- utilsScript: "../../build/js/utils.js?1680992740399",
5
+ utilsScript: "../../build/js/utils.js?1680993492797",
6
6
  });
7
7
  iti.promise.then(function() {
8
8
  statusElement.innerHTML = "Initialised!";
@@ -7,7 +7,7 @@ var errorMap = ["Invalid number", "Invalid country code", "Too short", "Too long
7
7
 
8
8
  // initialise plugin
9
9
  var iti = window.intlTelInput(input, {
10
- utilsScript: "../../build/js/utils.js?1680992740399"
10
+ utilsScript: "../../build/js/utils.js?1680993492797"
11
11
  });
12
12
 
13
13
  var reset = function() {
@@ -7,5 +7,5 @@ for (var i = 0; i < countryData.length; i++) {
7
7
  }
8
8
 
9
9
  window.intlTelInput(input, {
10
- utilsScript: "../../build/js/utils.js?1680992740399" // just for formatting/placeholders etc
10
+ utilsScript: "../../build/js/utils.js?1680993492797" // just for formatting/placeholders etc
11
11
  });
@@ -4,10 +4,10 @@ var inputMobile = document.querySelector("#mobile");
4
4
  window.intlTelInput(inputHome, {
5
5
  initialCountry: 'gb',
6
6
  placeholderNumberType: 'FIXED_LINE',
7
- utilsScript: "../../build/js/utils.js?1680992740399" // just for formatting/placeholders etc
7
+ utilsScript: "../../build/js/utils.js?1680993492797" // just for formatting/placeholders etc
8
8
  });
9
9
  window.intlTelInput(inputMobile, {
10
10
  initialCountry: 'gb',
11
11
  placeholderNumberType: 'MOBILE',
12
- utilsScript: "../../build/js/utils.js?1680992740399"
12
+ utilsScript: "../../build/js/utils.js?1680993492797"
13
13
  });
@@ -3,7 +3,7 @@ var input = document.querySelector("#phone"),
3
3
 
4
4
  var iti = window.intlTelInput(input, {
5
5
  nationalMode: true,
6
- utilsScript: "../../build/js/utils.js?1680992740399" // just for formatting/placeholders etc
6
+ utilsScript: "../../build/js/utils.js?1680993492797" // just for formatting/placeholders etc
7
7
  });
8
8
 
9
9
  var handleChange = function() {
@@ -4,5 +4,5 @@ window.intlTelInput(input, {
4
4
  "ee", "fo", "fi", "fr", "de", "gi", "gr", "va", "hu", "is", "ie", "it", "lv",
5
5
  "li", "lt", "lu", "mk", "mt", "md", "mc", "me", "nl", "no", "pl", "pt", "ro",
6
6
  "ru", "sm", "rs", "sk", "si", "es", "se", "ch", "ua", "gb"],
7
- utilsScript: "../../build/js/utils.js?1680992740399" // just for formatting/placeholders etc
7
+ utilsScript: "../../build/js/utils.js?1680993492797" // just for formatting/placeholders etc
8
8
  });
@@ -4,8 +4,8 @@
4
4
  <meta charset="utf-8">
5
5
  <title>Example: Modify country data</title>
6
6
  <link rel="stylesheet" href="../css/prism.css">
7
- <link rel="stylesheet" href="../../build/css/intlTelInput.css?1680992740399">
8
- <link rel="stylesheet" href="../../build/css/demo.css?1680992740399">
7
+ <link rel="stylesheet" href="../../build/css/intlTelInput.css?1680993492797">
8
+ <link rel="stylesheet" href="../../build/css/demo.css?1680993492797">
9
9
 
10
10
 
11
11
  <!-- Global site tag (gtag.js) - Google Analytics -->
@@ -36,7 +36,7 @@ for (var i = 0; i &lt; countryData.length; i++) {
36
36
  }
37
37
 
38
38
  window.intlTelInput(input, {
39
- utilsScript: &quot;../../build/js/utils.js?1680992740399&quot; // just for formatting/placeholders etc
39
+ utilsScript: &quot;../../build/js/utils.js?1680993492797&quot; // just for formatting/placeholders etc
40
40
  });
41
41
  </code></pre>
42
42
 
@@ -46,7 +46,7 @@ window.intlTelInput(input, {
46
46
  </div>
47
47
 
48
48
  <script src="../js/prism.js"></script>
49
- <script src="../../build/js/intlTelInput.js?1680992740399"></script>
50
- <script src="./js/modifyCountryData.js?1680992740399"></script>
49
+ <script src="../../build/js/intlTelInput.js?1680993492797"></script>
50
+ <script src="./js/modifyCountryData.js?1680993492797"></script>
51
51
  </body>
52
52
  </html>
@@ -4,8 +4,8 @@
4
4
  <meta charset="utf-8">
5
5
  <title>Example: Multiple Instances</title>
6
6
  <link rel="stylesheet" href="../css/prism.css">
7
- <link rel="stylesheet" href="../../build/css/intlTelInput.css?1680992740399">
8
- <link rel="stylesheet" href="../../build/css/demo.css?1680992740399">
7
+ <link rel="stylesheet" href="../../build/css/intlTelInput.css?1680993492797">
8
+ <link rel="stylesheet" href="../../build/css/demo.css?1680993492797">
9
9
 
10
10
 
11
11
  <!-- Global site tag (gtag.js) - Google Analytics -->
@@ -36,12 +36,12 @@ var inputMobile = document.querySelector(&quot;#mobile&quot;);
36
36
  window.intlTelInput(inputHome, {
37
37
  initialCountry: &#39;gb&#39;,
38
38
  placeholderNumberType: &#39;FIXED_LINE&#39;,
39
- utilsScript: &quot;../../build/js/utils.js?1680992740399&quot; // just for formatting/placeholders etc
39
+ utilsScript: &quot;../../build/js/utils.js?1680993492797&quot; // just for formatting/placeholders etc
40
40
  });
41
41
  window.intlTelInput(inputMobile, {
42
42
  initialCountry: &#39;gb&#39;,
43
43
  placeholderNumberType: &#39;MOBILE&#39;,
44
- utilsScript: &quot;../../build/js/utils.js?1680992740399&quot;
44
+ utilsScript: &quot;../../build/js/utils.js?1680993492797&quot;
45
45
  });
46
46
  </code></pre>
47
47
 
@@ -54,7 +54,7 @@ Mobile: <input id="mobile" type="tel">
54
54
  </div>
55
55
 
56
56
  <script src="../js/prism.js"></script>
57
- <script src="../../build/js/intlTelInput.js?1680992740399"></script>
58
- <script src="./js/multipleInstances.js?1680992740399"></script>
57
+ <script src="../../build/js/intlTelInput.js?1680993492797"></script>
58
+ <script src="./js/multipleInstances.js?1680993492797"></script>
59
59
  </body>
60
60
  </html>
@@ -4,8 +4,8 @@
4
4
  <meta charset="utf-8">
5
5
  <title>Example: National Mode</title>
6
6
  <link rel="stylesheet" href="../css/prism.css">
7
- <link rel="stylesheet" href="../../build/css/intlTelInput.css?1680992740399">
8
- <link rel="stylesheet" href="../../build/css/demo.css?1680992740399">
7
+ <link rel="stylesheet" href="../../build/css/intlTelInput.css?1680993492797">
8
+ <link rel="stylesheet" href="../../build/css/demo.css?1680993492797">
9
9
 
10
10
 
11
11
  <!-- Global site tag (gtag.js) - Google Analytics -->
@@ -34,7 +34,7 @@
34
34
 
35
35
  var iti = window.intlTelInput(input, {
36
36
  nationalMode: true,
37
- utilsScript: &quot;../../build/js/utils.js?1680992740399&quot; // just for formatting/placeholders etc
37
+ utilsScript: &quot;../../build/js/utils.js?1680993492797&quot; // just for formatting/placeholders etc
38
38
  });
39
39
 
40
40
  var handleChange = function() {
@@ -57,7 +57,7 @@ input.addEventListener(&#39;keyup&#39;, handleChange);
57
57
  </div>
58
58
 
59
59
  <script src="../js/prism.js"></script>
60
- <script src="../../build/js/intlTelInput.js?1680992740399"></script>
61
- <script src="./js/nationalMode.js?1680992740399"></script>
60
+ <script src="../../build/js/intlTelInput.js?1680993492797"></script>
61
+ <script src="./js/nationalMode.js?1680993492797"></script>
62
62
  </body>
63
63
  </html>
@@ -4,8 +4,8 @@
4
4
  <meta charset="utf-8">
5
5
  <title>Example: Only countries option</title>
6
6
  <link rel="stylesheet" href="../css/prism.css">
7
- <link rel="stylesheet" href="../../build/css/intlTelInput.css?1680992740399">
8
- <link rel="stylesheet" href="../../build/css/demo.css?1680992740399">
7
+ <link rel="stylesheet" href="../../build/css/intlTelInput.css?1680993492797">
8
+ <link rel="stylesheet" href="../../build/css/demo.css?1680993492797">
9
9
 
10
10
 
11
11
  <!-- Global site tag (gtag.js) - Google Analytics -->
@@ -33,7 +33,7 @@ window.intlTelInput(input, {
33
33
  &quot;ee&quot;, &quot;fo&quot;, &quot;fi&quot;, &quot;fr&quot;, &quot;de&quot;, &quot;gi&quot;, &quot;gr&quot;, &quot;va&quot;, &quot;hu&quot;, &quot;is&quot;, &quot;ie&quot;, &quot;it&quot;, &quot;lv&quot;,
34
34
  &quot;li&quot;, &quot;lt&quot;, &quot;lu&quot;, &quot;mk&quot;, &quot;mt&quot;, &quot;md&quot;, &quot;mc&quot;, &quot;me&quot;, &quot;nl&quot;, &quot;no&quot;, &quot;pl&quot;, &quot;pt&quot;, &quot;ro&quot;,
35
35
  &quot;ru&quot;, &quot;sm&quot;, &quot;rs&quot;, &quot;sk&quot;, &quot;si&quot;, &quot;es&quot;, &quot;se&quot;, &quot;ch&quot;, &quot;ua&quot;, &quot;gb&quot;],
36
- utilsScript: &quot;../../build/js/utils.js?1680992740399&quot; // just for formatting/placeholders etc
36
+ utilsScript: &quot;../../build/js/utils.js?1680993492797&quot; // just for formatting/placeholders etc
37
37
  });
38
38
  </code></pre>
39
39
 
@@ -43,7 +43,7 @@ window.intlTelInput(input, {
43
43
  </div>
44
44
 
45
45
  <script src="../js/prism.js"></script>
46
- <script src="../../build/js/intlTelInput.js?1680992740399"></script>
47
- <script src="./js/onlyCountriesEurope.js?1680992740399"></script>
46
+ <script src="../../build/js/intlTelInput.js?1680993492797"></script>
47
+ <script src="./js/onlyCountriesEurope.js?1680993492797"></script>
48
48
  </body>
49
49
  </html>
@@ -2,9 +2,9 @@ var input = document.querySelector("#phone");
2
2
  window.intlTelInput(input, {
3
3
  initialCountry: "auto",
4
4
  geoIpLookup: function(callback) {
5
- fetch("http://ip-api.com/json")
5
+ fetch("https://ipapi.co/json")
6
6
  .then(function(res) { return res.json(); })
7
- .then(function(data) { callback(data.countryCode); })
7
+ .then(function(data) { callback(data.country_code); })
8
8
  .catch(function() { callback("us"); });
9
9
  },
10
10
  utilsScript: "../../build/js/utils.js?<%= time %>" // just for formatting/placeholders etc
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "intl-tel-input",
3
- "version": "18.0.2",
3
+ "version": "18.1.0",
4
4
  "description": "A JavaScript plugin for entering and validating international telephone numbers",
5
5
  "keywords": [
6
6
  "international",
@@ -248,7 +248,7 @@ $mobilePopupMargin: 30px !default;
248
248
  // now that we have digits in this section, it needs this visual separation
249
249
  background-color: $hoverColor;
250
250
  }
251
- .iti__selected-dial-code {
251
+ &.iti--show-flags .iti__selected-dial-code {
252
252
  margin-left: $arrowPadding;
253
253
  }
254
254
  }
@@ -48,6 +48,8 @@ const defaults = {
48
48
  preferredCountries: ['us', 'gb'],
49
49
  // display the country dial code next to the selected flag
50
50
  separateDialCode: false,
51
+ // option to hide the flags - must be used with separateDialCode, or allowDropdown=false
52
+ showFlags: true,
51
53
  // specify the path to the libphonenumber script to enable validation/formatting
52
54
  utilsScript: '',
53
55
  };
@@ -101,6 +103,13 @@ class Iti {
101
103
  // if separateDialCode enabled, do not insert dial codes
102
104
  if (this.options.separateDialCode) this.options.autoInsertDialCode = false;
103
105
 
106
+ // force showFlags=true if there's a dropdown and we're not displaying the dial code,
107
+ // as otherwise you just have a down arrow on it's own which doesn't make sense
108
+ const forceShowFlags = (this.options.allowDropdown && !this.options.separateDialCode);
109
+ if (!this.options.showFlags && forceShowFlags) {
110
+ this.options.showFlags = true;
111
+ }
112
+
104
113
  // we cannot just test screen size as some smartphones/website meta tags will report desktop
105
114
  // resolutions
106
115
  // Note: for some reason jasmine breaks if you put this in the main Plugin function with the
@@ -313,45 +322,62 @@ class Iti {
313
322
  this.telInput.setAttribute('autocomplete', 'off');
314
323
  }
315
324
 
325
+ const {
326
+ allowDropdown,
327
+ separateDialCode,
328
+ showFlags,
329
+ customContainer,
330
+ hiddenInput,
331
+ dropdownContainer,
332
+ } = this.options;
333
+
316
334
  // containers (mostly for positioning)
317
335
  let parentClass = 'iti';
318
- if (this.options.allowDropdown) parentClass += ' iti--allow-dropdown';
319
- if (this.options.separateDialCode) parentClass += ' iti--separate-dial-code';
320
- if (this.options.customContainer) {
321
- parentClass += ' ';
322
- parentClass += this.options.customContainer;
336
+ if (allowDropdown) parentClass += ' iti--allow-dropdown';
337
+ if (separateDialCode) parentClass += ' iti--separate-dial-code';
338
+ if (showFlags) parentClass += ' iti--show-flags';
339
+ if (customContainer) {
340
+ parentClass += ` ${customContainer}`;
323
341
  }
324
342
 
325
343
  const wrapper = this._createEl('div', { class: parentClass });
326
344
  this.telInput.parentNode.insertBefore(wrapper, this.telInput);
327
- this.flagsContainer = this._createEl('div', { class: 'iti__flag-container' }, wrapper);
345
+ // only hide the flagsContainer if allowDropdown, showFlags and separateDialCode are all false
346
+ const showFlagsContainer = (allowDropdown || showFlags || separateDialCode);
347
+ if (showFlagsContainer) {
348
+ this.flagsContainer = this._createEl('div', { class: 'iti__flag-container' }, wrapper);
349
+ }
328
350
  wrapper.appendChild(this.telInput);
329
351
 
330
352
  // selected flag (displayed to left of input)
331
353
  // using Aria tags for "Select-Only Combobox Example"
332
354
  // https://www.w3.org/WAI/ARIA/apg/patterns/combobox/examples/combobox-select-only/
333
- this.selectedFlag = this._createEl('div', {
334
- class: 'iti__selected-flag',
335
- ...(this.options.allowDropdown && {
336
- role: 'combobox',
337
- 'aria-haspopup': 'listbox',
338
- 'aria-controls': `iti-${this.id}__country-listbox`,
339
- 'aria-owns': `iti-${this.id}__country-listbox`,
340
- 'aria-expanded': 'false',
341
- 'aria-label': 'Telephone country code',
342
- }),
343
- }, this.flagsContainer);
344
- this.selectedFlagInner = this._createEl('div', { class: 'iti__flag' }, this.selectedFlag);
345
-
346
- if (this.telInput.disabled) {
355
+ if (showFlagsContainer) {
356
+ this.selectedFlag = this._createEl('div', {
357
+ class: 'iti__selected-flag',
358
+ ...(allowDropdown && {
359
+ role: 'combobox',
360
+ 'aria-haspopup': 'listbox',
361
+ 'aria-controls': `iti-${this.id}__country-listbox`,
362
+ 'aria-owns': `iti-${this.id}__country-listbox`,
363
+ 'aria-expanded': 'false',
364
+ 'aria-label': 'Telephone country code',
365
+ }),
366
+ }, this.flagsContainer);
367
+ }
368
+ if (showFlags) {
369
+ this.selectedFlagInner = this._createEl('div', { class: 'iti__flag' }, this.selectedFlag);
370
+ }
371
+
372
+ if (this.selectedFlag && this.telInput.disabled) {
347
373
  this.selectedFlag.setAttribute('aria-disabled', 'true');
348
374
  }
349
375
 
350
- if (this.options.separateDialCode) {
376
+ if (separateDialCode) {
351
377
  this.selectedDialCode = this._createEl('div', { class: 'iti__selected-dial-code' }, this.selectedFlag);
352
378
  }
353
379
 
354
- if (this.options.allowDropdown) {
380
+ if (allowDropdown) {
355
381
  if (!this.telInput.disabled) {
356
382
  // make element focusable and tab navigable
357
383
  this.selectedFlag.setAttribute('tabindex', '0');
@@ -377,7 +403,7 @@ class Iti {
377
403
  this._appendListItems(this.countries, 'iti__standard');
378
404
 
379
405
  // create dropdownContainer markup
380
- if (this.options.dropdownContainer) {
406
+ if (dropdownContainer) {
381
407
  this.dropdown = this._createEl('div', { class: 'iti iti--container' });
382
408
  this.dropdown.appendChild(this.countryList);
383
409
  } else {
@@ -385,8 +411,8 @@ class Iti {
385
411
  }
386
412
  }
387
413
 
388
- if (this.options.hiddenInput) {
389
- let hiddenInputName = this.options.hiddenInput;
414
+ if (hiddenInput) {
415
+ let hiddenInputName = hiddenInput;
390
416
  const name = this.telInput.getAttribute('name');
391
417
  if (name) {
392
418
  const i = name.lastIndexOf('[');
@@ -415,7 +441,9 @@ class Iti {
415
441
  // open the list item
416
442
  tmp += `<li class='iti__country ${className}' tabIndex='-1' id='iti-${this.id}__item-${c.iso2}${idSuffix}' role='option' data-dial-code='${c.dialCode}' data-country-code='${c.iso2}' aria-selected='false'>`;
417
443
  // add the flag
418
- tmp += `<div class='iti__flag-box'><div class='iti__flag iti__${c.iso2}'></div></div>`;
444
+ if (this.options.showFlags) {
445
+ tmp += `<div class='iti__flag-box'><div class='iti__flag iti__${c.iso2}'></div></div>`;
446
+ }
419
447
  // and the country name and dial code
420
448
  tmp += `<span class='iti__country-name'>${c.name}</span>`;
421
449
  tmp += `<span class='iti__dial-code'>+${c.dialCode}</span>`;
@@ -979,10 +1007,14 @@ class Iti {
979
1007
  this.defaultCountry = this.selectedCountryData.iso2;
980
1008
  }
981
1009
 
982
- this.selectedFlagInner.setAttribute('class', `iti__flag iti__${countryCode}`);
1010
+ if (this.options.showFlags) {
1011
+ this.selectedFlagInner.setAttribute('class', `iti__flag iti__${countryCode}`);
1012
+ }
983
1013
  // update the selected country's title attribute
984
- const title = (countryCode) ? `${this.selectedCountryData.name}: +${this.selectedCountryData.dialCode}` : 'Unknown';
985
- this.selectedFlag.setAttribute('title', title);
1014
+ if (this.selectedFlag) {
1015
+ const title = (countryCode) ? `${this.selectedCountryData.name}: +${this.selectedCountryData.dialCode}` : 'Unknown';
1016
+ this.selectedFlag.setAttribute('title', title);
1017
+ }
986
1018
 
987
1019
  if (this.options.separateDialCode) {
988
1020
  const dialCode = this.selectedCountryData.dialCode ? `+${this.selectedCountryData.dialCode}` : '';
@@ -1020,6 +1052,8 @@ class Iti {
1020
1052
 
1021
1053
  // when the input is in a hidden container during initialisation, we must inject some markup
1022
1054
  // into the end of the DOM to calculate the correct offsetWidth
1055
+ // NOTE: this is only used when separateDialCode is enabled, so flagsContainer and selectedFlag
1056
+ // will definitely exist
1023
1057
  _getHiddenSelectedFlagWidth() {
1024
1058
  // to get the right styling to apply, all we need is a shallow clone of the container,
1025
1059
  // and then to inject a deep clone of the selectedFlag element
@@ -1378,7 +1412,7 @@ class Iti {
1378
1412
  setCountry(originalCountryCode) {
1379
1413
  const countryCode = originalCountryCode.toLowerCase();
1380
1414
  // check if already selected
1381
- if (!this.selectedFlagInner.classList.contains(`iti__${countryCode}`)) {
1415
+ if (this.selectedCountryData.iso2 !== countryCode) {
1382
1416
  this._setFlag(countryCode);
1383
1417
  this._updateDialCode(this.selectedCountryData.dialCode);
1384
1418
  this._triggerCountryChange();