Skip to content

Commit 797ac13

Browse files
committed
[fix] stringify JSON attributes for HTML serialization
1 parent b23e24b commit 797ac13

2 files changed

Lines changed: 4 additions & 7 deletions

File tree

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "echarts-jsx",
3-
"version": "1.3.0",
3+
"version": "1.3.1",
44
"license": "LGPL-3.0",
55
"author": "shiy2008@gmail.com",
66
"description": "A real JSX wrapper for ECharts based on TypeScript & Web components",

source/Proxy.ts

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -50,9 +50,6 @@ export abstract class ProxyElement<T extends object>
5050
this.#data[key] = value;
5151

5252
switch (typeof value) {
53-
case 'object':
54-
if (!value) this.removeAttribute(name);
55-
break;
5653
case 'boolean':
5754
if (value) super.setAttribute(name, name + '');
5855
else super.removeAttribute(name);
@@ -67,9 +64,9 @@ export abstract class ProxyElement<T extends object>
6764
if (value != null)
6865
super.setAttribute(
6966
name,
70-
typeof value === 'string'
71-
? value
72-
: JSON.stringify(value)
67+
typeof value === 'object'
68+
? JSON.stringify(value)
69+
: value
7370
);
7471
else if (
7572
EventKeyPattern.test(key) &&

0 commit comments

Comments
 (0)