From 1a02da8b8a81b88a6f0f56e5900fa85cc6dda198 Mon Sep 17 00:00:00 2001 From: Suchita Lad Date: Wed, 16 Jul 2025 12:16:01 +0530 Subject: Added objectToStyle function --- blocks/eda-frontend/src/utils/GalleryUtils.js | 20 +++++++------------- 1 file changed, 7 insertions(+), 13 deletions(-) diff --git a/blocks/eda-frontend/src/utils/GalleryUtils.js b/blocks/eda-frontend/src/utils/GalleryUtils.js index 32aac61e..767f4f05 100644 --- a/blocks/eda-frontend/src/utils/GalleryUtils.js +++ b/blocks/eda-frontend/src/utils/GalleryUtils.js @@ -177,21 +177,15 @@ export const styleToObject = (style) => { } export const objectToStyle = (styleObject) => { - let style = '' - - for (const key in styleObject) { - if (Object.hasOwnProperty.call(styleObject, key)) { - const value = styleObject[key] - if (value !== undefined && value !== null && value !== '') { - if (key === 'default') { - style += `${value};` - } else { - style += `${key}=${value};` - } - } + let style = styleObject.default + for (const [key, value] of Object.entries(styleObject)) { + if (key === 'default') { + continue } + if (value !== undefined && value !== null && value !== '') { + style += `;${key}=${value}` + } } - return style } -- cgit