Skip to content

Commit 1daa39f

Browse files
Merge pull request #446 from remarkablemark/fix/html-dom-parser
fix: ensure backwards compatibility for html-dom-parser's ES Module
2 parents 03747b8 + 5f724cc commit 1daa39f

File tree

2 files changed

+10
-0
lines changed

2 files changed

+10
-0
lines changed

index.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,11 @@ var domToReact = require('./lib/dom-to-react');
22
var attributesToProps = require('./lib/attributes-to-props');
33
var htmlToDOM = require('html-dom-parser');
44

5+
// support backwards compatibility for ES Module
6+
htmlToDOM =
7+
/* istanbul ignore next */
8+
typeof htmlToDOM.default === 'function' ? htmlToDOM.default : htmlToDOM;
9+
510
var domParserOptions = { lowerCaseAttributeNames: false };
611

712
/**

test/index.test.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,18 +6,23 @@ const { render } = require('./helpers');
66
describe('module', () => {
77
it('exports default', () => {
88
expect(parse.default).toBe(parse);
9+
expect(parse.default).toBeInstanceOf(Function);
910
});
1011

1112
it('exports domToReact', () => {
1213
expect(parse.domToReact).toBe(require('../lib/dom-to-react'));
14+
expect(parse.domToReact).toBeInstanceOf(Function);
1315
});
1416

1517
it('exports htmlToDOM', () => {
1618
expect(parse.htmlToDOM).toBe(require('html-dom-parser'));
19+
expect(parse.htmlToDOM).toBeInstanceOf(Function);
20+
expect(parse.htmlToDOM.default).toBe(undefined);
1721
});
1822

1923
it('exports attributesToProps', () => {
2024
expect(parse.attributesToProps).toBe(require('../lib/attributes-to-props'));
25+
expect(parse.attributesToProps).toBeInstanceOf(Function);
2126
});
2227
});
2328

0 commit comments

Comments
 (0)