Skip to content

Commit 4fc3a73

Browse files
fix(index): export domhandler classes
Fixes #777 Export domhandler classes: - Comment - Node - ProcessingInstruction - Text
1 parent 4c3f41b commit 4fc3a73

File tree

3 files changed

+21
-6
lines changed

3 files changed

+21
-6
lines changed

index.d.ts

+4-3
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,16 @@
11
// TypeScript Version: 4.7
2+
/* eslint-disable no-undef, no-unused-vars */
23

3-
import { ParserOptions } from 'htmlparser2';
44
import {
55
Comment,
6-
DomHandlerOptions,
76
Element,
87
Node,
98
ProcessingInstruction,
10-
Text
9+
Text,
10+
type DomHandlerOptions
1111
} from 'domhandler';
1212
import htmlToDOM from 'html-dom-parser';
13+
import { ParserOptions } from 'htmlparser2';
1314

1415
import attributesToProps from './lib/attributes-to-props';
1516
import domToReact from './lib/dom-to-react';

index.js

+11-3
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
1-
var domToReact = require('./lib/dom-to-react');
2-
var attributesToProps = require('./lib/attributes-to-props');
1+
var domhandler = require('domhandler');
32
var htmlToDOM = require('html-dom-parser');
43

4+
var attributesToProps = require('./lib/attributes-to-props');
5+
var domToReact = require('./lib/dom-to-react');
6+
57
// support backwards compatibility for ES Module
68
htmlToDOM =
79
/* istanbul ignore next */
@@ -36,7 +38,13 @@ function HTMLReactParser(html, options) {
3638
HTMLReactParser.domToReact = domToReact;
3739
HTMLReactParser.htmlToDOM = htmlToDOM;
3840
HTMLReactParser.attributesToProps = attributesToProps;
39-
HTMLReactParser.Element = require('domhandler').Element;
41+
42+
// domhandler
43+
HTMLReactParser.Comment = domhandler.Comment;
44+
HTMLReactParser.Element = domhandler.Element;
45+
HTMLReactParser.Node = domhandler.Node;
46+
HTMLReactParser.ProcessingInstruction = domhandler.ProcessingInstruction;
47+
HTMLReactParser.Text = domhandler.Text;
4048

4149
// support CommonJS and ES Modules
4250
module.exports = HTMLReactParser;

index.mjs

+6
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,12 @@ import HTMLReactParser from './index.js';
33
export var domToReact = HTMLReactParser.domToReact;
44
export var htmlToDOM = HTMLReactParser.htmlToDOM;
55
export var attributesToProps = HTMLReactParser.attributesToProps;
6+
7+
// domhandler
8+
export var Comment = HTMLReactParser.Comment;
69
export var Element = HTMLReactParser.Element;
10+
export var Node = HTMLReactParser.Node;
11+
export var ProcessingInstruction = HTMLReactParser.ProcessingInstruction;
12+
export var Text = HTMLReactParser.Text;
713

814
export default HTMLReactParser;

0 commit comments

Comments
 (0)