Skip to content

Commit 339888b

Browse files
authored
Render empty attributes as empty instead of "true" (#42)
1 parent 63200ed commit 339888b

File tree

2 files changed

+5
-1
lines changed

2 files changed

+5
-1
lines changed

src/to-vdom.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,6 @@ function getProps(attrs) {
5252
let props = {};
5353
for (let i=0; i<len; i++) {
5454
let { name, value } = attrs[i];
55-
if (value==='') value = true;
5655
if (name.substring(0,2)==='on' && walk.options.allowEvents){
5756
value = new Function(value); // eslint-disable-line no-new-func
5857
}

test/index.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,11 @@ describe('Markup', () => {
8585
);
8686
});
8787

88+
it('should render empty attributes as empty', () => {
89+
render(<Markup markup={'<img alt="" src="" />'} />, scratch);
90+
expect(scratch.firstChild.innerHTML).to.equal('<img alt="" src="">');
91+
});
92+
8893
it('should render mapped components from XML', () => {
8994
const Foo = ({ a, b, camelCasedProperty, children }) =>
9095
(<div class="foo" camelCasedProperty={camelCasedProperty} data-a={a} data-b={b}>{ children }</div>);

0 commit comments

Comments
 (0)