From 556f6b82e6a06d7f2ea0a854c240cc8893ac55a7 Mon Sep 17 00:00:00 2001 From: Jonas Langhabel Date: Tue, 5 Jan 2021 11:04:38 +0100 Subject: [PATCH 1/3] fix: parse json theme string for standalone tag #1248 --- src/standalone.tsx | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/standalone.tsx b/src/standalone.tsx index f0eda0b126..430d435abc 100644 --- a/src/standalone.tsx +++ b/src/standalone.tsx @@ -32,7 +32,13 @@ function parseOptionsFromElement(element: Element) { const res = {}; for (const attrName in attrMap) { const optionName = attrName.replace(/-(.)/g, (_, $1) => $1.toUpperCase()); - res[optionName] = attrMap[attrName]; + let attr = attrMap[attrName]; + + if (attrName === 'theme') { + attr = JSON.parse(attr); + } + + res[optionName] = attr; // TODO: normalize options } return res; From 419dbc71f014fb6df1b6a5c6aaa037fcd182de80 Mon Sep 17 00:00:00 2001 From: Roman Hotsiy Date: Thu, 15 Apr 2021 10:08:31 +0300 Subject: [PATCH 2/3] Update src/standalone.tsx --- src/standalone.tsx | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/src/standalone.tsx b/src/standalone.tsx index 430d435abc..74de3e50aa 100644 --- a/src/standalone.tsx +++ b/src/standalone.tsx @@ -32,13 +32,8 @@ function parseOptionsFromElement(element: Element) { const res = {}; for (const attrName in attrMap) { const optionName = attrName.replace(/-(.)/g, (_, $1) => $1.toUpperCase()); - let attr = attrMap[attrName]; - - if (attrName === 'theme') { - attr = JSON.parse(attr); - } - - res[optionName] = attr; + const attr = attrMap[attrName]; + res[optionName] = attrName === 'theme' ? JSON.parse(attr) : attr; // TODO: normalize options } return res; From 8c2f6cf11c985d61c39c1df4770cbf8a9c1b7599 Mon Sep 17 00:00:00 2001 From: Roman Hotsiy Date: Thu, 15 Apr 2021 10:09:20 +0300 Subject: [PATCH 3/3] Update src/standalone.tsx --- src/standalone.tsx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/standalone.tsx b/src/standalone.tsx index 74de3e50aa..12b65daa60 100644 --- a/src/standalone.tsx +++ b/src/standalone.tsx @@ -32,8 +32,8 @@ function parseOptionsFromElement(element: Element) { const res = {}; for (const attrName in attrMap) { const optionName = attrName.replace(/-(.)/g, (_, $1) => $1.toUpperCase()); - const attr = attrMap[attrName]; - res[optionName] = attrName === 'theme' ? JSON.parse(attr) : attr; + const optionValue = attrMap[attrName]; + res[optionName] = attrName === 'theme' ? JSON.parse(optionValue) : optionValue; // TODO: normalize options } return res;