From 335f77cc4806bd911b66c3e733bef193e42c5a84 Mon Sep 17 00:00:00 2001 From: Christian Kaisermann Date: Fri, 17 May 2019 15:23:47 -0300 Subject: [PATCH] =?UTF-8?q?fix:=20=F0=9F=90=9B=20data=20attributes=20witho?= =?UTF-8?q?ut=20value=20outputting=20as=20"true"?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/compile/render-dom/wrappers/Element/Attribute.ts | 2 +- .../runtime/samples/attribute-dataset-without-value/_config.js | 3 +++ .../samples/attribute-dataset-without-value/main.svelte | 1 + 3 files changed, 5 insertions(+), 1 deletion(-) create mode 100644 test/runtime/samples/attribute-dataset-without-value/_config.js create mode 100644 test/runtime/samples/attribute-dataset-without-value/main.svelte diff --git a/src/compile/render-dom/wrappers/Element/Attribute.ts b/src/compile/render-dom/wrappers/Element/Attribute.ts index 9841f4e85d..5007724f34 100644 --- a/src/compile/render-dom/wrappers/Element/Attribute.ts +++ b/src/compile/render-dom/wrappers/Element/Attribute.ts @@ -187,7 +187,7 @@ export default class AttributeWrapper { : property_name ? `${element.var}.${property_name} = ${value};` : is_dataset - ? `${element.var}.dataset.${camel_case_name} = ${value};` + ? `${element.var}.dataset.${camel_case_name} = ${value === true ? '""' : value};` : `${method}(${element.var}, "${name}", ${value === true ? '""' : value});` ); diff --git a/test/runtime/samples/attribute-dataset-without-value/_config.js b/test/runtime/samples/attribute-dataset-without-value/_config.js new file mode 100644 index 0000000000..934f44eb06 --- /dev/null +++ b/test/runtime/samples/attribute-dataset-without-value/_config.js @@ -0,0 +1,3 @@ +export default { + html: '
', +}; diff --git a/test/runtime/samples/attribute-dataset-without-value/main.svelte b/test/runtime/samples/attribute-dataset-without-value/main.svelte new file mode 100644 index 0000000000..ed7d532652 --- /dev/null +++ b/test/runtime/samples/attribute-dataset-without-value/main.svelte @@ -0,0 +1 @@ +