From bb0904f20d1332d5e81332a16178c640b6a0c41d Mon Sep 17 00:00:00 2001 From: Frederic Junod Date: Fri, 12 Jan 2018 13:34:03 +0100 Subject: [PATCH] Fix invalid named color detection If the named color is invalid, the value is not stored into the property. --- src/ol/color.js | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/ol/color.js b/src/ol/color.js index 2a5cf1f6f6..1f1b1bc713 100644 --- a/src/ol/color.js +++ b/src/ol/color.js @@ -45,10 +45,14 @@ export function asString(color) { function fromNamed(color) { const el = document.createElement('div'); el.style.color = color; - document.body.appendChild(el); - const rgb = getComputedStyle(el).color; - document.body.removeChild(el); - return rgb; + if (el.style.color !== '') { + document.body.appendChild(el); + const rgb = getComputedStyle(el).color; + document.body.removeChild(el); + return rgb; + } else { + return ''; + } }