| OLD | NEW |
| 1 // Copyright 2013 the V8 project authors. All rights reserved. | 1 // Copyright 2013 the V8 project authors. All rights reserved. |
| 2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
| 3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
| 4 // met: | 4 // met: |
| 5 // | 5 // |
| 6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
| 7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
| 8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
| 9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
| 10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
| (...skipping 27 matching lines...) Expand all Loading... |
| 38 | 38 |
| 39 var Intl = {}; | 39 var Intl = {}; |
| 40 | 40 |
| 41 var undefined = global.undefined; | 41 var undefined = global.undefined; |
| 42 | 42 |
| 43 var AVAILABLE_SERVICES = ['collator', | 43 var AVAILABLE_SERVICES = ['collator', |
| 44 'numberformat', | 44 'numberformat', |
| 45 'dateformat', | 45 'dateformat', |
| 46 'breakiterator']; | 46 'breakiterator']; |
| 47 | 47 |
| 48 var NORMALIZATION_FORMS = ['NFC', |
| 49 'NFD', |
| 50 'NFKC', |
| 51 'NFKD']; |
| 52 |
| 48 /** | 53 /** |
| 49 * Caches available locales for each service. | 54 * Caches available locales for each service. |
| 50 */ | 55 */ |
| 51 var AVAILABLE_LOCALES = { | 56 var AVAILABLE_LOCALES = { |
| 52 'collator': undefined, | 57 'collator': undefined, |
| 53 'numberformat': undefined, | 58 'numberformat': undefined, |
| 54 'dateformat': undefined, | 59 'dateformat': undefined, |
| 55 'breakiterator': undefined | 60 'breakiterator': undefined |
| 56 }; | 61 }; |
| 57 | 62 |
| (...skipping 1923 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1981 return compare(collator, this, that); | 1986 return compare(collator, this, that); |
| 1982 }, | 1987 }, |
| 1983 writable: true, | 1988 writable: true, |
| 1984 configurable: true, | 1989 configurable: true, |
| 1985 enumerable: false | 1990 enumerable: false |
| 1986 }); | 1991 }); |
| 1987 %FunctionSetName($String.prototype.localeCompare, 'localeCompare'); | 1992 %FunctionSetName($String.prototype.localeCompare, 'localeCompare'); |
| 1988 %FunctionRemovePrototype($String.prototype.localeCompare); | 1993 %FunctionRemovePrototype($String.prototype.localeCompare); |
| 1989 %SetNativeFlag($String.prototype.localeCompare); | 1994 %SetNativeFlag($String.prototype.localeCompare); |
| 1990 | 1995 |
| 1996 /** |
| 1997 * Unicode normalization. This method is called with one argument that |
| 1998 * specifies the normalization form. |
| 1999 * If none is specified, "NFC" is assumed. |
| 2000 * If the form is not one of "NFC", "NFD", "NFKC", or "NFKD", then throw |
| 2001 * a RangeError Exception. |
| 2002 */ |
| 2003 $Object.defineProperty($String.prototype, 'normalize', { |
| 2004 value: function(that) { |
| 2005 if (%_IsConstructCall()) { |
| 2006 throw new $TypeError(ORDINARY_FUNCTION_CALLED_AS_CONSTRUCTOR); |
| 2007 } |
| 2008 |
| 2009 if (IS_NULL_OR_UNDEFINED(this)) { |
| 2010 throw new $TypeError('Method invoked on undefined or null value.'); |
| 2011 } |
| 2012 |
| 2013 var form = $String(%_Arguments(0) || 'NFC'); |
| 2014 |
| 2015 var normalizationForm = NORMALIZATION_FORMS.indexOf(form); |
| 2016 if (normalizationForm !== -1) { |
| 2017 return %StringNormalize(this, normalizationForm); |
| 2018 } |
| 2019 throw new $RangeError('The normalization form should be one of ' |
| 2020 + NORMALIZATION_FORMS.join(', ') + '.'); |
| 2021 }, |
| 2022 writable: true, |
| 2023 configurable: true, |
| 2024 enumerable: false |
| 2025 }); |
| 2026 %FunctionSetName($String.prototype.normalize, 'normalize'); |
| 2027 %FunctionRemovePrototype($String.prototype.normalize); |
| 2028 %SetNativeFlag($String.prototype.normalize); |
| 2029 |
| 1991 | 2030 |
| 1992 /** | 2031 /** |
| 1993 * Formats a Number object (this) using locale and options values. | 2032 * Formats a Number object (this) using locale and options values. |
| 1994 * If locale or options are omitted, defaults are used. | 2033 * If locale or options are omitted, defaults are used. |
| 1995 */ | 2034 */ |
| 1996 $Object.defineProperty($Number.prototype, 'toLocaleString', { | 2035 $Object.defineProperty($Number.prototype, 'toLocaleString', { |
| 1997 value: function() { | 2036 value: function() { |
| 1998 if (%_IsConstructCall()) { | 2037 if (%_IsConstructCall()) { |
| 1999 throw new $TypeError(ORDINARY_FUNCTION_CALLED_AS_CONSTRUCTOR); | 2038 throw new $TypeError(ORDINARY_FUNCTION_CALLED_AS_CONSTRUCTOR); |
| 2000 } | 2039 } |
| (...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2107 writable: true, | 2146 writable: true, |
| 2108 configurable: true, | 2147 configurable: true, |
| 2109 enumerable: false | 2148 enumerable: false |
| 2110 }); | 2149 }); |
| 2111 %FunctionSetName($Date.prototype.toLocaleTimeString, 'toLocaleTimeString'); | 2150 %FunctionSetName($Date.prototype.toLocaleTimeString, 'toLocaleTimeString'); |
| 2112 %FunctionRemovePrototype($Date.prototype.toLocaleTimeString); | 2151 %FunctionRemovePrototype($Date.prototype.toLocaleTimeString); |
| 2113 %SetNativeFlag($Date.prototype.toLocaleTimeString); | 2152 %SetNativeFlag($Date.prototype.toLocaleTimeString); |
| 2114 | 2153 |
| 2115 return Intl; | 2154 return Intl; |
| 2116 }())}); | 2155 }())}); |
| OLD | NEW |