Browse Source

JS: libphonenumber v5.1.2 - AYTF fix

pull/567/head
Lara Scheidegger 13 years ago
committed by Mihaela Rosca
parent
commit
5475cbf960
3 changed files with 16 additions and 2 deletions
  1. +1
    -1
      javascript/README
  2. +4
    -1
      javascript/i18n/phonenumbers/asyoutypeformatter.js
  3. +11
    -0
      javascript/i18n/phonenumbers/asyoutypeformatter_test.js

+ 1
- 1
javascript/README View File

@ -25,7 +25,7 @@ pages with your web browser:
How to update:
==============
The JavaScript library is ported from the Java implementation (revision 516).
The JavaScript library is ported from the Java implementation (revision 524).
When the Java project gets updated follow these steps to update the JavaScript
project:


+ 4
- 1
javascript/i18n/phonenumbers/asyoutypeformatter.js View File

@ -358,7 +358,10 @@ i18n.phonenumbers.AsYouTypeFormatter.prototype.getAvailableFormats_ =
for (var i = 0; i < formatListLength; ++i) {
/** @type {i18n.phonenumbers.NumberFormat} */
var format = formatList[i];
if (this.isCompleteNumber_ ||
/** @type {boolean} */
var nationalPrefixIsUsedByCountry =
this.currentMetaData_.hasNationalPrefix();
if (!nationalPrefixIsUsedByCountry || this.isCompleteNumber_ ||
format.getNationalPrefixOptionalWhenFormatting() ||
this.phoneUtil_.formattingRuleHasFirstGroupOnly(
format.getNationalPrefixFormattingRule())) {


+ 11
- 0
javascript/i18n/phonenumbers/asyoutypeformatter_test.js View File

@ -1105,6 +1105,17 @@ function testAYTFShortNumberFormattingFix_MX() {
assertEquals('+52 800 123 4567', f.inputDigit('7'));
}
function testAYTFNoNationalPrefix() {
/** @type {i18n.phonenumbers.AsYouTypeFormatter} */
var f = new i18n.phonenumbers.AsYouTypeFormatter(RegionCode.IT);
assertEquals('3', f.inputDigit('3'));
assertEquals('33', f.inputDigit('3'));
assertEquals('333', f.inputDigit('3'));
assertEquals('333 3', f.inputDigit('3'));
assertEquals('333 33', f.inputDigit('3'));
assertEquals('333 333', f.inputDigit('3'));
}
function testAYTFShortNumberFormattingFix_US() {
// For the US, an initial 1 is treated specially.
/** @type {i18n.phonenumbers.AsYouTypeFormatter} */


Loading…
Cancel
Save