Skip to content

Commit

Permalink
feat: export domhandler's Element
Browse files Browse the repository at this point in the history
  • Loading branch information
natterstefan committed Sep 26, 2021
1 parent bcf3d57 commit 0473e83
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 2 deletions.
3 changes: 1 addition & 2 deletions README.md
Expand Up @@ -188,8 +188,7 @@ parse('<p id="replace">text</p>', {
For TypeScript projects, you may need to check that `domNode` is an instance of domhandler's `Element`:

```tsx
import { HTMLReactParserOptions } from 'html-react-parser';
import { Element } from 'domhandler/lib/node';
import { HTMLReactParserOptions, Element } from 'html-react-parser';

const options: HTMLReactParserOptions = {
replace: domNode => {
Expand Down
2 changes: 2 additions & 0 deletions index.js
@@ -1,6 +1,7 @@
var domToReact = require('./lib/dom-to-react');
var attributesToProps = require('./lib/attributes-to-props');
var htmlToDOM = require('html-dom-parser');
var { Element } = require('domhandler/lib/node');

var domParserOptions = { lowerCaseAttributeNames: false };

Expand Down Expand Up @@ -31,6 +32,7 @@ function HTMLReactParser(html, options) {
HTMLReactParser.domToReact = domToReact;
HTMLReactParser.htmlToDOM = htmlToDOM;
HTMLReactParser.attributesToProps = attributesToProps;
HTMLReactParser.Element = Element;

// support CommonJS and ES Modules
module.exports = HTMLReactParser;
Expand Down
1 change: 1 addition & 0 deletions index.mjs
Expand Up @@ -3,5 +3,6 @@ import HTMLReactParser from './index.js';
export var domToReact = HTMLReactParser.domToReact;
export var htmlToDOM = HTMLReactParser.htmlToDOM;
export var attributesToProps = HTMLReactParser.attributesToProps;
export var Element = HTMLReactParser.Element;

export default HTMLReactParser;

0 comments on commit 0473e83

Please sign in to comment.