From 0473e832ac65b3e8ce5f8da69c740cbd84f62863 Mon Sep 17 00:00:00 2001 From: Stefan Natter Date: Sun, 26 Sep 2021 16:10:48 +0200 Subject: [PATCH] feat: export domhandler's Element --- README.md | 3 +-- index.js | 2 ++ index.mjs | 1 + 3 files changed, 4 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index f5cffe39..284103aa 100644 --- a/README.md +++ b/README.md @@ -188,8 +188,7 @@ parse('

text

', { 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 => { diff --git a/index.js b/index.js index 3929d5a5..d0979e26 100644 --- a/index.js +++ b/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 }; @@ -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; diff --git a/index.mjs b/index.mjs index 70bd49bd..018feb9c 100644 --- a/index.mjs +++ b/index.mjs @@ -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;