Skip to content

Commit

Permalink
fix(Renderer): enable returning boolean false from props mapping func…
Browse files Browse the repository at this point in the history
…tion
  • Loading branch information
DxCx authored and HHogg committed Feb 8, 2018
1 parent 9e88337 commit a903476
Show file tree
Hide file tree
Showing 2 changed files with 49 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/renderer.js
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ export default class Renderer {
if (keyValue) {
return {
key: keyValue.key || prop,
value: keyValue.value || propValue,
value: keyValue.hasOwnProperty('value') ? keyValue.value : propValue,
};
}
} else if (typeof this.options.remarkableProps[prop] === 'string') {
Expand Down
48 changes: 48 additions & 0 deletions test/renderer.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -1267,6 +1267,54 @@ Code
}],
}]);
});

it('boolean value (true)', () => {
assertProps(render(`
![](http://google.com "true")
`, {}, {
remarkableProps: {
title(value) {
return {
value: value && value.toLowerCase() == 'true',
};
}
},
}), [{
children: [{
props: {
alt: '',
src: 'http://google.com',
title: true,
},
}],
}]);
});

it('boolean value (false)', () => {
assertProps(render(`
![](http://google.com "false")
`, {}, {
remarkableProps: {
title(value) {
return {
value: value && value.toLowerCase() == 'true',
};
}
},
}), [{
children: [{
props: {
alt: '',
src: 'http://google.com',
title: false,
},
}],
}]);
});
});

it('string', () => {
Expand Down

0 comments on commit a903476

Please sign in to comment.