Skip to content

Commit b48005c

Browse files
committed
Fix multiple spread props in one element
1 parent 6cb4a7a commit b48005c

File tree

2 files changed

+7
-0
lines changed

2 files changed

+7
-0
lines changed

src/index.mjs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,9 @@ function build(statics) {
6767
if (!props) props = 'Object.assign({},';
6868
else props = 'Object.assign({},' + props + '},';
6969
}
70+
else {
71+
props += '},';
72+
}
7073
props += field + ',{';
7174
}
7275
else if (propName) {

test/index.test.mjs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,10 @@ describe('htm', () => {
8484
expect(html`<a ...${{ c: 'bar' }}><b ...${{ d: 'baz' }}/></a>`).toEqual(h('a', { c: 'bar' }, h('b', { d: 'baz' }) ));
8585
});
8686

87+
test('multiple spread props in one element', () => {
88+
expect(html`<a ...${{ foo: 'bar' }} ...${{ quux: 'baz' }} />`).toEqual({ tag: 'a', props: { foo: 'bar', quux: 'baz' }, children: [] });
89+
});
90+
8791
test('mixed spread + static props', () => {
8892
expect(html`<a b ...${{ foo: 'bar' }} />`).toEqual({ tag: 'a', props: { b: true, foo: 'bar' }, children: [] });
8993
expect(html`<a b c ...${{ foo: 'bar' }} />`).toEqual({ tag: 'a', props: { b: true, c: true, foo: 'bar' }, children: [] });

0 commit comments

Comments
 (0)