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
This commit is contained in:
Lucas Galfasó
2013-05-04 21:44:14 -03:00
committed by Pete Bacon Darwin
parent ef5bc6c7c3
commit b3d7a038d7
247 changed files with 13236 additions and 13231 deletions

View File

@@ -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);
});
});

View File

@@ -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 = {};