Skip to content

Commit

Permalink
Fix rendering to string of "draggable" attribute
Browse files Browse the repository at this point in the history
  • Loading branch information
dfilatov committed Sep 10, 2018
1 parent 62eadf6 commit 4bb4fdc
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 9 deletions.
8 changes: 4 additions & 4 deletions spec/renderToString/renderToString.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,13 +40,13 @@ describe('renderToString', () => {
});

it('should be rendered properly for overloaded with "true" attribute', () => {
expect(h('a', { download : true }).renderToString())
.to.equal('<a download></a>');
expect(h('div', { draggable : true }).renderToString())
.to.equal('<div draggable="true"></div>');
});

it('should be rendered properly for overloaded with "false" attribute', () => {
expect(h('a', { download : false }).renderToString())
.to.equal('<a></a>');
expect(h('div', { draggable : false }).renderToString())
.to.equal('<div draggable="false"></div>');
});

it('shouldn\'t render null value', () => {
Expand Down
7 changes: 2 additions & 5 deletions src/client/domAttrs.js
Original file line number Diff line number Diff line change
Expand Up @@ -99,14 +99,10 @@ function removeSelectValue(node) {
}

function attrToString(name, value) {
if(value === false) {
return '';
}

const attrName = getAttrName(name);

return attrName &&
attrName + (value === true? '' : '="' + escapeAttr(value) + '"');
attrName + '="' + escapeAttr(value) + '"';
}

function booleanAttrToString(name, value) {
Expand Down Expand Up @@ -188,6 +184,7 @@ attrsCfg.autoPlay = BOOLEAN_ATTR_CFG;
attrsCfg.checked = BOOLEAN_PROP_CFG;
attrsCfg.controls = DEFAULT_PROP_CFG;
attrsCfg.disabled = BOOLEAN_ATTR_CFG;
attrsCfg.download = BOOLEAN_ATTR_CFG;
attrsCfg.id = DEFAULT_PROP_CFG;
attrsCfg.ismap = BOOLEAN_ATTR_CFG;
attrsCfg.loop = DEFAULT_PROP_CFG;
Expand Down

0 comments on commit 4bb4fdc

Please sign in to comment.