From 02b2d71eb3eb4c7b6e81348528ae85639fe1046c Mon Sep 17 00:00:00 2001 From: Justin Greywolf Date: Tue, 5 Dec 2023 07:57:39 -0800 Subject: [PATCH] Update packages/mermaid/src/diagrams/class/classDb.ts Co-authored-by: Sidharth Vinod --- .../mermaid/src/diagrams/class/classDb.ts | 24 ++++++++----------- 1 file changed, 10 insertions(+), 14 deletions(-) diff --git a/packages/mermaid/src/diagrams/class/classDb.ts b/packages/mermaid/src/diagrams/class/classDb.ts index 2141c93a2..4b2231dc1 100644 --- a/packages/mermaid/src/diagrams/class/classDb.ts +++ b/packages/mermaid/src/diagrams/class/classDb.ts @@ -457,20 +457,16 @@ export const addClassesToNamespace = function (id: string, classNames: string[]) } }; -export const setCssStyle = function (id: string, style: string[]) { - if (style !== undefined && style !== null) { - const thisClass = classes[id]; - if (thisClass !== undefined) { - style.forEach(function (s) { - if (s.includes(',')) { - const styles = s.split(','); - styles.forEach(function (newStyle) { - thisClass.styles.push(newStyle); - }); - } else { - thisClass.styles.push(s); - } - }); +export const setCssStyle = function (id: string, styles: string[]) { + const thisClass = classes[id]; + if (!styles || !thisClass) { + return; + } + for (const s of styles) { + if (s.includes(',')) { + thisClass.styles = thisClass.styles.concat(s.split(',')); + } else { + thisClass.styles.push(s); } } };