From 067d74de9f8c116dd52ba21b3984d579d6e72f54 Mon Sep 17 00:00:00 2001 From: Yohan Boniface Date: Mon, 8 Jan 2024 16:35:41 +0100 Subject: [PATCH] fix: icon element is undefined when clustered --- umap/static/umap/js/umap.icon.js | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/umap/static/umap/js/umap.icon.js b/umap/static/umap/js/umap.icon.js index b1fd7f2d..a6df88a5 100644 --- a/umap/static/umap/js/umap.icon.js +++ b/umap/static/umap/js/umap.icon.js @@ -208,15 +208,16 @@ L.U.Icon.makeIconElement = function (src, parent) { return icon } -L.U.Icon.setIconContrast = function (el, parent, src, bgcolor) { +L.U.Icon.setIconContrast = function (icon, parent, src, bgcolor) { /* - * el: the element we'll adapt the style, it can be an image or text + * icon: the element we'll adapt the style, it can be an image or text * parent: the element we'll consider to decide whether to adapt the style, * by looking at its background color * src: the raw "icon" value, can be an URL, a path, text, emoticon, etc. * bgcolor: the background color, used for caching and in case we cannot guess the * parent background color - */ + */ + if (!icon) return if (L.DomUtil.contrastedColor(parent, bgcolor)) { // Decide whether to switch svg to white or not, but do it @@ -224,10 +225,10 @@ L.U.Icon.setIconContrast = function (el, parent, src, bgcolor) { if (L.Util.isPath(src) && src.endsWith('.svg')) { // Must be called after icon container is added to the DOM // An image - el.style.filter = 'invert(1)' - } else if (!el.src) { + icon.style.filter = 'invert(1)' + } else if (!icon.src) { // Text icon - el.style.color = 'white' + icon.style.color = 'white' } } }