aboutsummaryrefslogtreecommitdiffstats
path: root/i18n
diff options
context:
space:
mode:
authorLucas Galfasó2013-05-04 21:44:14 -0300
committerBrian Ford2013-08-12 16:23:38 -0700
commit751c77f87b34389c5b85a23c71080d367c42d31b (patch)
tree1e29a46da7d0275363a0c3528394134670c9fdd6 /i18n
parent634ac03c5efb7a35bb8107dfc686bf834e77f019 (diff)
downloadangular.js-751c77f87b34389c5b85a23c71080d367c42d31b.tar.bz2
fix(i18n): Do not transform arrays into objects
Do not trasnform arrays into objects when generating the locale objects Add unit test for this check
Diffstat (limited to 'i18n')
-rw-r--r--i18n/spec/closureI18nExtractorSpec.js5
-rw-r--r--i18n/src/closureI18nExtractor.js2
2 files changed, 6 insertions, 1 deletions
diff --git a/i18n/spec/closureI18nExtractorSpec.js b/i18n/spec/closureI18nExtractorSpec.js
index 87a9d455..f1455963 100644
--- a/i18n/spec/closureI18nExtractorSpec.js
+++ b/i18n/spec/closureI18nExtractorSpec.js
@@ -257,5 +257,10 @@ describe("serializeContent", function() {
var serializedContent = closureI18nExtractor.serializeContent(newTestLocaleInfo());
expect((/[^\u0001-\u007f]/).test(serializedContent)).toBe(false);
});
+ it("should not transform arrays into objects", function() {
+ var serializedContent = closureI18nExtractor.serializeContent(newTestLocaleInfo().fr_CA);
+ var deserializedLocale = eval("(" + serializedContent + ")");
+ expect(deserializedLocale.DATETIME_FORMATS.MONTH.length).not.toBe(undefined);
+ });
});
diff --git a/i18n/src/closureI18nExtractor.js b/i18n/src/closureI18nExtractor.js
index 13d42143..05e3997d 100644
--- a/i18n/src/closureI18nExtractor.js
+++ b/i18n/src/closureI18nExtractor.js
@@ -116,7 +116,7 @@ function canonicalizeForJsonStringify(unused_key, object) {
// 2. https://code.google.com/p/v8/issues/detail?id=164
// ECMA-262 does not specify enumeration order. The de facto standard
// is to match insertion order, which V8 also does ...
- if (typeof object != "object") {
+ if (typeof object != "object" || Object.prototype.toString.apply(object) === '[object Array]') {
return object;
}
var result = {};