Skip to content

Commit

Permalink
Add support for dangerouslySetInnerHTML
Browse files Browse the repository at this point in the history
  • Loading branch information
deini committed Jan 16, 2018
1 parent 48290a3 commit 526f5c0
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -66,9 +66,9 @@ function applyRef (e, ref) {

// Ensures attrs, events and props are all set as the consumer intended.
function ensureAttrs (objs) {
const { attrs, events, ref, key, ...props } = objs || {};
const { attrs, events, ref, key, dangerouslySetInnerHTML, ...props } = objs || {};
const newRef = ensureRef({ attrs, events, props, ref });
return { ref: newRef, key }
return { ref: newRef, key, dangerouslySetInnerHTML }
}

// Ensures a ref is supplied that set each member appropriately and that
Expand Down
8 changes: 8 additions & 0 deletions tests/index.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,14 @@ describe('Custom adapter', () => {
it('h(nodeName, { key })', () => {
expect(val((name,props) => props)('test', { key: 'foo' }).key).toBe('foo');
});

it('h(nodeName, { dangerouslySetInnerHTML })', () => {
const div = val((name,props) => props)('div', {
dangerouslySetInnerHTML: 'foo'
});

expect(div.dangerouslySetInnerHTML).toBe('foo');
});
});

describe('Default adapter (DOM)', () => {
Expand Down

0 comments on commit 526f5c0

Please sign in to comment.