From 79ca3cfd699a6c491d709adc71506919dab88f3b Mon Sep 17 00:00:00 2001 From: Xavier Mamano Date: Sat, 11 Aug 2012 17:28:59 +0200 Subject: [PATCH] Avoid breaking the "OpenLayers.String.format" execution when searching for an attribute in an undefined object. --- lib/OpenLayers/BaseTypes.js | 4 +++- tests/BaseTypes.html | 4 ++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/lib/OpenLayers/BaseTypes.js b/lib/OpenLayers/BaseTypes.js index b0c96956a7..a4b4f3f3fe 100644 --- a/lib/OpenLayers/BaseTypes.js +++ b/lib/OpenLayers/BaseTypes.js @@ -127,7 +127,9 @@ OpenLayers.String = { if (i == 0) { replacement = context; } - + if (replacement === undefined) { + break; + } replacement = replacement[subs[i]]; } diff --git a/tests/BaseTypes.html b/tests/BaseTypes.html index cc391003da..340b0bbaa5 100644 --- a/tests/BaseTypes.html +++ b/tests/BaseTypes.html @@ -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" );