From 13ac44088f53f4e20991bb0f4c2816ab759bca8a Mon Sep 17 00:00:00 2001 From: lararennie Date: Mon, 3 Oct 2016 14:31:36 +0200 Subject: [PATCH] Fixing array indexOf to use closure instead of native array function, since IE8 hasn't implemented this. (#1376) --- javascript/i18n/phonenumbers/demo-compiled.js | 113 +++++++++--------- .../i18n/phonenumbers/phonenumberutil.js | 10 +- 2 files changed, 62 insertions(+), 61 deletions(-) diff --git a/javascript/i18n/phonenumbers/demo-compiled.js b/javascript/i18n/phonenumbers/demo-compiled.js index 5fa00c6fd..0e215165f 100644 --- a/javascript/i18n/phonenumbers/demo-compiled.js +++ b/javascript/i18n/phonenumbers/demo-compiled.js @@ -1,15 +1,16 @@ -(function(){for(var aa="function"==typeof Object.defineProperties?Object.defineProperty:function(a,b,c){if(c.get||c.set)throw new TypeError("ES3 does not support getters and setters.");a!=Array.prototype&&a!=Object.prototype&&(a[b]=c.value)},k="undefined"!=typeof window&&window===this?this:"undefined"!=typeof global&&null!=global?global:this,l=["String","prototype","repeat"],ba=0;baa||1342177279>>=1)b+=b;return c};fa!=ea&&null!=fa&&aa(k,da,{configurable:!0,writable:!0,value:fa}); -function ga(a){var b=typeof a;if("object"==b)if(a){if(a instanceof Array)return"array";if(a instanceof Object)return b;var c=Object.prototype.toString.call(a);if("[object Window]"==c)return"object";if("[object Array]"==c||"number"==typeof a.length&&"undefined"!=typeof a.splice&&"undefined"!=typeof a.propertyIsEnumerable&&!a.propertyIsEnumerable("splice"))return"array";if("[object Function]"==c||"undefined"!=typeof a.call&&"undefined"!=typeof a.propertyIsEnumerable&&!a.propertyIsEnumerable("call"))return"function"}else return"null"; -else if("function"==b&&"undefined"==typeof a.call)return"object";return b}function n(a){return"string"==typeof a}function p(a,b){function c(){}c.prototype=b.prototype;a.ha=b.prototype;a.prototype=new c;a.prototype.constructor=a;a.ma=function(a,c,f){for(var d=Array(arguments.length-2),e=2;ec?Math.max(0,a.length+c):c;if(n(a))return n(b)&&1==b.length?a.indexOf(b,c):-1;for(;cb?1:aa||1342177279>>=1)b+=b;return d}});ca("Math.sign",function(a){return a?a:function(a){a=Number(a);return!a||isNaN(a)?a:0c?Math.max(0,a.length+c):c;if(k(a))return k(b)&&1==b.length?a.indexOf(b,c):-1;for(;cb?1:aa.length?!1:N(eb,a)}function nb(a){return N(cb,a)?O(a,Wa):O(a,L)}function ob(a){var b=nb(a.toString());C(a);a.a(b)}function O(a,b){for(var c=new B,d,e=a.length,f=0;f=e)a=c;else if(d=d.substring(0,e),d=O(d,L),d.length)if(g=g.clone(),La(g,4),d=[g],g=x(b,1),c=R(b),g in J){a=T(a,g,U(g));if(e=wb(d,c))d=e.clone(),e=x(e,4),0e?2:c[c.length-1]=f&&f<=e;++f)if(d=parseInt(c.substring(0,f),10),d in J)return b.a(c.substring(f)),d;return 0} -function Gb(a,b,c,d,e){if(!a.length)return 0;a=new B(a);var f;b&&(f=u(b,11));null==f&&(f="NonMatch");var g=a.toString();if(g.length)if(M.test(g))g=g.replace(M,""),C(a),a.a(nb(g)),f=1;else{g=new RegExp(f);ob(a);f=a.toString();if(f.search(g))f=!1;else{var g=f.match(g)[0].length,h=f.substring(g).match(Za);h&&null!=h[1]&&0=a.b.length)throw"Phone number too short after IDD";if(c=Fb(a,c))return v(e, -1,c),c;throw"Invalid country calling code";}if(b&&(f=x(b,10),g=""+f,h=a.toString(),!h.lastIndexOf(g,0))){var m=new B(h.substring(g.length)),g=u(b,1),h=new RegExp(x(g,2));Hb(m,b,null);b=m.toString();if(!N(h,a.toString())&&N(h,b)||3==Db(a.toString(),g))return c.a(b),d&&v(e,6,10),v(e,1,f),f}v(e,1,0);return 0} -function Hb(a,b,c){var d=a.toString(),e=d.length,f=u(b,15);if(e&&null!=f&&f.length){var g=new RegExp("^(?:"+f+")");if(e=g.exec(d)){var f=new RegExp(x(u(b,1),2)),h=N(f,d),m=e.length-1;b=u(b,16);if(null!=b&&b.length&&null!=e[m]&&e[m].length){if(d=d.replace(g,b),!h||N(f,d))c&&0g.b.length)throw"The string supplied is too short to be a phone number";b&&(a=new B,c=new B(g.toString()),Hb(c,b,a),2!=Db(c.toString(),u(b,1))&&(g=c,d&&v(f,7,a.toString())));d=g.toString();a=d.length;if(2>a)throw"The string supplied is too short to be a phone number";if(17a.length?!1:N($a,a)}function ib(a){return N(Ya,a)?O(a,Ra):O(a,L)}function jb(a){var b=ib(a.toString());C(a);a.a(b)}function O(a,b){for(var c=new B,d,e=a.length,f=0;f=e)a=c;else if(d=d.substring(0,e),d=O(d,L),d.length)if(g=g.clone(),Ga(g,4),d=[g],g=x(b,1),c=R(b),g in J){a=T(a,g,U(g));if(e=rb(d,c))d=e.clone(),e=x(e,4),0e?2:c[c.length-1]=f&&f<=e;++f)if(d=parseInt(c.substring(0,f),10),d in J)return b.a(c.substring(f)),d;return 0} +function Bb(a,b,c,d,e){if(!a.length)return 0;a=new B(a);var f;b&&(f=u(b,11));null==f&&(f="NonMatch");var g=a.toString();if(g.length)if(M.test(g))g=g.replace(M,""),C(a),a.a(ib(g)),f=1;else{g=new RegExp(f);jb(a);f=a.toString();if(f.search(g))f=!1;else{var g=f.match(g)[0].length,h=f.substring(g).match(Ua);h&&null!=h[1]&&0=a.b.length)throw"Phone number too short after IDD";if(c=Ab(a,c))return v(e, +1,c),c;throw"Invalid country calling code";}if(b&&(f=x(b,10),g=""+f,h=a.toString(),!h.lastIndexOf(g,0))){var m=new B(h.substring(g.length)),g=u(b,1),h=new RegExp(x(g,2));Cb(m,b,null);b=m.toString();if(!N(h,a.toString())&&N(h,b)||3==yb(a.toString(),g))return c.a(b),d&&v(e,6,10),v(e,1,f),f}v(e,1,0);return 0} +function Cb(a,b,c){var d=a.toString(),e=d.length,f=u(b,15);if(e&&null!=f&&f.length){var g=new RegExp("^(?:"+f+")");if(e=g.exec(d)){var f=new RegExp(x(u(b,1),2)),h=N(f,d),m=e.length-1;b=u(b,16);if(null!=b&&b.length&&null!=e[m]&&e[m].length){if(d=d.replace(g,b),!h||N(f,d))c&&0g.b.length)throw"The string supplied is too short to be a phone number";b&&(a=new B,c=new B(g.toString()),Cb(c,b,a),2!=yb(c.toString(),u(b,1))&&(g=c,d&&0a)throw"The string supplied is too short to be a phone number";if(17 0 && - numberDesc.possibleLengthArray().indexOf(actualLength) == -1) { + goog.array.indexOf(numberDesc.possibleLengthArray(), + actualLength) == -1) { return false; } return i18n.phonenumbers.PhoneNumberUtil.matchesEntirely_( @@ -3139,7 +3140,7 @@ i18n.phonenumbers.PhoneNumberUtil.prototype.testNumberLength_ = var possibleLengths = phoneNumberDesc.possibleLengthArray(); var localLengths = phoneNumberDesc.possibleLengthLocalOnlyArray(); var actualLength = number.length; - if (localLengths.indexOf(actualLength) > -1) { + if (goog.array.indexOf(localLengths, actualLength) > -1) { return i18n.phonenumbers.PhoneNumberUtil.ValidationResult.IS_POSSIBLE; } // There should always be "possibleLengths" set for every element. This will @@ -3158,9 +3159,8 @@ i18n.phonenumbers.PhoneNumberUtil.prototype.testNumberLength_ = // length, and higher than the lowest possible number length. However, we // don't currently have an enum to express this, so we return TOO_LONG in the // short-term. - // We could skip the first element; we've already checked it; but we prefer to - // check one value rather than create an extra object in this case. - return (possibleLengths.indexOf(actualLength) > -1) ? + // We skip the first element since we've already checked it. + return (goog.array.indexOf(possibleLengths, actualLength, 1) > -1) ? i18n.phonenumbers.PhoneNumberUtil.ValidationResult.IS_POSSIBLE : i18n.phonenumbers.PhoneNumberUtil.ValidationResult.TOO_LONG; };