Skip to content

Commit

Permalink
Render empty attributes as empty instead of "true" (#42)
Browse files Browse the repository at this point in the history
  • Loading branch information
vpzomtrrfrt authored Feb 4, 2021
1 parent 63200ed commit 339888b
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
1 change: 0 additions & 1 deletion src/to-vdom.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,6 @@ function getProps(attrs) {
let props = {};
for (let i=0; i<len; i++) {
let { name, value } = attrs[i];
if (value==='') value = true;
if (name.substring(0,2)==='on' && walk.options.allowEvents){
value = new Function(value); // eslint-disable-line no-new-func
}
Expand Down
5 changes: 5 additions & 0 deletions test/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,11 @@ describe('Markup', () => {
);
});

it('should render empty attributes as empty', () => {
render(<Markup markup={'<img alt="" src="" />'} />, scratch);
expect(scratch.firstChild.innerHTML).to.equal('<img alt="" src="">');
});

it('should render mapped components from XML', () => {
const Foo = ({ a, b, camelCasedProperty, children }) =>
(<div class="foo" camelCasedProperty={camelCasedProperty} data-a={a} data-b={b}>{ children }</div>);
Expand Down

0 comments on commit 339888b

Please sign in to comment.