Skip to content

Commit

Permalink
Merge pull request #1969 from sveltejs/gh-1852
Browse files Browse the repository at this point in the history
better handling of bare attribute names in DOM mode
  • Loading branch information
Rich-Harris authored Jan 13, 2019
2 parents 2d3dbdd + d033c83 commit efa7ad6
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/compile/render-dom/wrappers/Element/Attribute.ts
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ export default class AttributeWrapper {
? `${element.var}.${propertyName} = ${value};`
: isDataSet
? `${element.var}.dataset.${camelCaseName} = ${value};`
: `${method}(${element.var}, "${name}", ${value});`
: `${method}(${element.var}, "${name}", ${value === true ? '""' : value});`
);

block.builders.hydrate.addLine(statement);
Expand All @@ -207,9 +207,9 @@ export default class AttributeWrapper {
}

stringify() {
const value = this.node.chunks;
if (this.node.isTrue) return '';

if (value === true) return '';
const value = this.node.chunks;
if (value.length === 0) return `=""`;

return `="${value.map(chunk => {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export default {
html: '<div potato=""></div>'
};
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<div potato></div>

0 comments on commit efa7ad6

Please sign in to comment.