Avoid breaking the "OpenLayers.String.format" execution when searching for an attribute in an undefined object.

This commit is contained in:
Xavier Mamano
2012-08-11 17:28:59 +02:00
parent 970448effc
commit 79ca3cfd69
2 changed files with 5 additions and 3 deletions

View File

@@ -127,7 +127,9 @@ OpenLayers.String = {
if (i == 0) {
replacement = context;
}
if (replacement === undefined) {
break;
}
replacement = replacement[subs[i]];
}

View File

@@ -155,8 +155,8 @@
}
};
t.eq(
format("${a.b.c} ${a.b.e} ${a.b.q} ${a} ${a...b...c}", context),
"d f undefined [object Object] d",
format("${a.b.c} ${a.b.e} ${a.b.q} ${a} ${a...b...c} ${aa.b} ${a.bb.c}", context),
"d f undefined [object Object] d undefined undefined",
"attribute values that are objects are supported"
);