mirror of
https://github.com/zhigang1992/angular.js.git
synced 2026-04-29 13:25:40 +08:00
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:
committed by
Pete Bacon Darwin
parent
ef5bc6c7c3
commit
b3d7a038d7
@@ -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);
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
@@ -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 = {};
|
||||
|
||||
Reference in New Issue
Block a user