From 8807a0c3a20f87e0bb3a031637180a855abda44a Mon Sep 17 00:00:00 2001 From: danzel Date: Fri, 21 Jun 2013 15:15:01 +1200 Subject: [PATCH] White space formatting and make sure we don't hit null if the parent isn't visible. --- src/MarkerClusterGroup.js | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/src/MarkerClusterGroup.js b/src/MarkerClusterGroup.js index fa30630d3..d2b2683cf 100644 --- a/src/MarkerClusterGroup.js +++ b/src/MarkerClusterGroup.js @@ -390,14 +390,13 @@ L.MarkerClusterGroup = L.FeatureGroup.extend({ this._map = null; }, - getVisibleParent: function(marker){ - var vMarker = marker; - // TODO: Is this safe? No extra check needed to prevent infinite loop? - while(!vMarker._icon) { - vMarker = vMarker.__parent; - } - return vMarker; - }, + getVisibleParent: function(marker){ + var vMarker = marker; + while(vMarker !== null && !vMarker._icon) { + vMarker = vMarker.__parent; + } + return vMarker; + }, //Remove the given object from the given array _arraySplice: function (anArray, obj) {