Important: This documentation covers Yarn 1 (Classic).
For Yarn 2+ docs and migration guide, see yarnpkg.com.

Package detail

html-react-parser

remarkablemark5mMIT5.2.2TypeScript support: included

HTML to React parser.

html-react-parser, html, react, parser, dom

readme

html-react-parser

NPM

NPM version Bundlephobia minified + gzip Build Status codecov NPM downloads Discord

HTML to React parser that works on both the server (Node.js) and the client (browser):

HTMLReactParser(string[, options])

The parser converts an HTML string to one or more React elements.

To replace an element with another element, check out the replace option.

Example

import parse from 'html-react-parser';

parse('<p>Hello, World!</p>'); // React.createElement('p', {}, 'Hello, World!')

Replit | JSFiddle | StackBlitz | TypeScript | Examples

<summary>Table of Contents</summary>

Install

NPM:

npm install html-react-parser --save

Yarn:

yarn add html-react-parser

CDN:

<!-- HTMLReactParser depends on React -->
<script src="https://unpkg.com/react@18/umd/react.production.min.js"></script>
<script src="https://unpkg.com/html-react-parser@latest/dist/html-react-parser.min.js"></script>
<script>
  window.HTMLReactParser(/* string */);
</script>

Usage

Import ES module:

import parse from 'html-react-parser';

Or require CommonJS module:

const parse = require('html-react-parser').default;

Parse single element:

parse('<h1>single</h1>');

Parse multiple elements:

parse('<li>Item 1</li><li>Item 2</li>');

Make sure to render parsed adjacent elements under a parent element:

<ul>
  {parse(`
    <li>Item 1</li>
    <li>Item 2</li>
  `)}
</ul>

Parse nested elements:

parse('<body><p>Lorem ipsum</p></body>');

Parse element with attributes:

parse(
  '<hr id="foo" class="bar" data-attr="baz" custom="qux" style="top:42px;">',
);

replace

The replace option allows you to replace an element with another element.

The replace callback's first argument is domhandler's node:

parse('<br>', {
  replace(domNode) {
    console.dir(domNode, { depth: null });
  },
});
<summary>Console output</summary>

Element {
  type: 'tag',
  parent: null,
  prev: null,
  next: null,
  startIndex: null,
  endIndex: null,
  children: [],
  name: 'br',
  attribs: {}
}

The element is replaced if a valid React element is returned:

parse('<p id="replace">text</p>', {
  replace(domNode) {
    if (domNode.attribs && domNode.attribs.id === 'replace') {
      return <span>replaced</span>;
    }
  },
});

The second argument is the index:

parse('<br>', {
  replace(domNode, index) {
    console.assert(typeof index === 'number');
  },
});

[!NOTE] The index will restart at 0 when traversing the node's children so don't rely on index being a unique key. See #1259.

replace with TypeScript

You need to check that domNode is an instance of domhandler's Element:

import { HTMLReactParserOptions, Element } from 'html-react-parser';

const options: HTMLReactParserOptions = {
  replace(domNode) {
    if (domNode instanceof Element && domNode.attribs) {
      // ...
    }
  },
};

Or use a type assertion:

import { HTMLReactParserOptions, Element } from 'html-react-parser';

const options: HTMLReactParserOptions = {
  replace(domNode) {
    if ((domNode as Element).attribs) {
      // ...
    }
  },
};

If you're having issues, take a look at our Create React App example.

replace element and children

Replace the element and its children (see demo):

import parse, { domToReact } from 'html-react-parser';

const html = `
  <p id="main">
    <span class="prettify">
      keep me and make me pretty!
    </span>
  </p>
`;

const options = {
  replace({ attribs, children }) {
    if (!attribs) {
      return;
    }

    if (attribs.id === 'main') {
      return <h1 style={{ fontSize: 42 }}>{domToReact(children, options)}</h1>;
    }

    if (attribs.class === 'prettify') {
      return (
        <span style={{ color: 'hotpink' }}>
          {domToReact(children, options)}
        </span>
      );
    }
  },
};

parse(html, options);
<summary>HTML output</summary>

<h1 style="font-size:42px">
  <span style="color:hotpink">
    keep me and make me pretty!
  </span>
</h1>

replace element attributes

Convert DOM attributes to React props with attributesToProps:

import parse, { attributesToProps } from 'html-react-parser';

const html = `
  <main class="prettify" style="background: #fff; text-align: center;" />
`;

const options = {
  replace(domNode) {
    if (domNode.attribs && domNode.name === 'main') {
      const props = attributesToProps(domNode.attribs);
      return <div {...props} />;
    }
  },
};

parse(html, options);
<summary>HTML output</summary>

<div class="prettify" style="background:#fff;text-align:center"></div>

replace and remove element

Exclude an element from rendering by replacing it with <React.Fragment>:

parse('<p><br id="remove"></p>', {
  replace: ({ attribs }) => attribs?.id === 'remove' && <></>,
});
<summary>HTML output</summary>

<p></p>

transform

The transform option allows you to transform each element individually after it's parsed.

The transform callback's first argument is the React element:

parse('<br>', {
  transform(reactNode, domNode, index) {
    // this will wrap every element in a div
    return <div>{reactNode}</div>;
  },
});

library

The library option specifies the UI library. The default library is React.

To use Preact:

parse('<br>', {
  library: require('preact'),
});

Or a custom library:

parse('<br>', {
  library: {
    cloneElement: () => {
      /* ... */
    },
    createElement: () => {
      /* ... */
    },
    isValidElement: () => {
      /* ... */
    },
  },
});

htmlparser2

[!WARNING] htmlparser2 options don't work on the client-side (browser); they only work on the server-side (Node.js). By overriding the options, it can break universal rendering.

Default htmlparser2 options can be overridden in >=0.12.0.

To enable xmlMode:

parse('<p /><p />', {
  htmlparser2: {
    xmlMode: true,
  },
});

trim

By default, whitespace is preserved:

parse('<br>\n'); // [React.createElement('br'), '\n']

But certain elements like <table> will strip out invalid whitespace:

parse('<table>\n</table>'); // React.createElement('table')

To remove whitespace, enable the trim option:

parse('<br>\n', { trim: true }); // React.createElement('br')

However, intentional whitespace may be stripped out:

parse('<p> </p>', { trim: true }); // React.createElement('p')

Migration

v5

Migrated to TypeScript. CommonJS imports require the .default key:

const parse = require('html-react-parser').default;

If you're getting the error:

Argument of type 'ChildNode[]' is not assignable to parameter of type 'DOMNode[]'.

Then use type assertion:

domToReact(domNode.children as DOMNode[], options);

See #1126.

v4

htmlparser2 has been upgraded to v9.

v3

domhandler has been upgraded to v5 so some parser options like normalizeWhitespace have been removed.

Also, it's recommended to upgrade to the latest version of TypeScript.

v2

Since v2.0.0, Internet Explorer (IE) is no longer supported.

v1

TypeScript projects will need to update the types in v1.0.0.

For the replace option, you may need to do the following:

import { Element } from 'domhandler/lib/node';

parse('<br class="remove">', {
  replace(domNode) {
    if (domNode instanceof Element && domNode.attribs.class === 'remove') {
      return <></>;
    }
  },
});

Since v1.1.1, Internet Explorer 9 (IE9) is no longer supported.

FAQ

Is this XSS safe?

No, this library is not XSS (cross-site scripting) safe. See #94.

Does invalid HTML get sanitized?

No, this library does not sanitize HTML. See #124, #125, and #141.

Are <script> tags parsed?

Although <script> tags and their contents are rendered on the server-side, they're not evaluated on the client-side. See #98.

Attributes aren't getting called

The reason why your HTML attributes aren't getting called is because inline event handlers (e.g., onclick) are parsed as a string rather than a function. See #73.

Parser throws an error

If the parser throws an error, check if your arguments are valid. See "Does invalid HTML get sanitized?".

Is SSR supported?

Yes, server-side rendering on Node.js is supported by this library. See demo.

Elements aren't nested correctly

If your elements are nested incorrectly, check to make sure your HTML markup is valid. The HTML to DOM parsing will be affected if you're using self-closing syntax (/>) on non-void elements:

parse('<div /><div />'); // returns single element instead of array of elements

See #158.

Don't change case of tags

Tags are lowercased by default. To prevent that from happening, pass the htmlparser2 option:

const options = {
  htmlparser2: {
    lowerCaseTags: false,
  },
};
parse('<CustomElement>', options); // React.createElement('CustomElement')

[!WARNING] By preserving case-sensitivity of the tags, you may get rendering warnings like:

Warning: <CustomElement> is using incorrect casing. Use PascalCase for React components, or lowercase for HTML elements.

See #62 and example.

TS Error: Property 'attribs' does not exist on type 'DOMNode'

The TypeScript error occurs because DOMNode needs to be an instance of domhandler's Element. See migration or #199.

Can I enable trim for certain elements?

Yes, you can enable or disable trim for certain elements using the replace option. See #205.

Webpack build warnings

If you see the Webpack build warning:

export 'default' (imported as 'parse') was not found in 'html-react-parser'

Then update your Webpack config to:

// webpack.config.js
module.exports = {
  // ...
  resolve: {
    mainFields: ['browser', 'main', 'module'],
  },
};

See #238 and #213.

TypeScript error

If you see the TypeScript error:

node_modules/htmlparser2/lib/index.d.ts:2:23 - error TS1005: ',' expected.

2 export { Parser, type ParserOptions };
                        ~~~~~~~~~~~~~

Then upgrade to the latest version of typescript. See #748.

Performance

Run benchmark:

npm run benchmark

Output of benchmark run on MacBook Pro 2021:

html-to-react - Single x 1,018,239 ops/sec ±0.43% (94 runs sampled)
html-to-react - Multiple x 380,037 ops/sec ±0.61% (97 runs sampled)
html-to-react - Complex x 35,091 ops/sec ±0.50% (96 runs sampled)

Run Size Limit:

npx size-limit

Contributors

Code Contributors

This project exists thanks to all the people who contribute. [Contribute].

Code Contributors

Financial Contributors

Become a financial contributor and help us sustain our community. [Contribute]

Individuals

Financial Contributors - Individuals

Organizations

Support this project with your organization. Your logo will show up here with a link to your website. [Contribute]

Financial Contributors - Organization 0 Financial Contributors - Organization 1 Financial Contributors - Organization 2 Financial Contributors - Organization 3 Financial Contributors - Organization 4 Financial Contributors - Organization 5 Financial Contributors - Organization 6 Financial Contributors - Organization 7 Financial Contributors - Organization 8 Financial Contributors - Organization 9

Support

License

MIT

changelog

Changelog

5.2.2 (2024-12-25)

Build System

  • deps: bump html-dom-parser from 5.0.12 to 5.0.13 (#1652) (ff0b897)

5.2.1 (2024-12-16)

Bug Fixes

  • package: bump html-dom-parser to 5.0.12 so that \\r isn't escaped (#1642) (a1ef928), closes #1634

5.2.0 (2024-12-06)

Features

  • package: add react 19 to package.json peerDependencies (8b6506c), closes #1455 #1501

5.1.19 (2024-12-04)

Bug Fixes

5.1.18 (2024-10-06)

Bug Fixes

  • deps: bump style-to-js from 1.1.15 to 1.1.16 (#1561) (4892aa2)

5.1.17 (2024-10-03)

Build System

  • deps: bump style-to-js from 1.1.14 to 1.1.15 (#1555) (6aae441)

5.1.16 (2024-09-11)

Build System

  • deps: bump style-to-js from 1.1.13 to 1.1.14 (#1514) (e7a1de6)

5.1.15 (2024-08-29)

Build System

  • deps: bump html-dom-parser from 5.0.9 to 5.0.10 (#1506) (5d01407)

5.1.14 (2024-08-28)

Build System

  • deps: bump style-to-js from 1.1.12 to 1.1.13 (#1502) (2fdc000)

5.1.13 (2024-08-26)

Continuous Integration

  • github: publish package to npm registry with provenance (e098038)

5.1.12 (2024-07-18)

Build System

  • deps: bump html-dom-parser from 5.0.8 to 5.0.9 (#1466) (1c0bfa0)

5.1.11 (2024-07-17)

Bug Fixes

  • package: match allowed peer dependency ranges of react and @types/react (#1463) (0809ac5), closes #1462

5.1.10 (2024-03-28)

Build System

  • deps: bump style-to-js from 1.1.11 to 1.1.12 (#1380) (b7fb86d)

5.1.9 (2024-03-19)

Build System

  • deps: bump style-to-js from 1.1.10 to 1.1.11 (#1368) (6e14815)

5.1.8 (2024-02-27)

Build System

  • package: make @types/react an optional peerDependency (8be504c)

5.1.7 (2024-02-19)

Bug Fixes

  • package: set dependency @types/react to 17 or 18 (0605477), closes #1320

5.1.6 (2024-02-16)

Bug Fixes

5.1.5 (2024-02-14)

Bug Fixes

  • esm: fix attributes-to-props and dom-to-react exported types (e3c7931)
  • package: move @types/react from devDependencies to dependencies (78b7a8e), closes #1313

5.1.4 (2024-02-12)

Bug Fixes

  • esm: fix exported types (7a94d61), closes #1305
  • types: use React.JSX instead of the global JSX namespace (a25f41c)

5.1.3 (2024-02-12)

Build System

  • deps: bump html-dom-parser from 5.0.7 to 5.0.8 (#1307) (00ee71b)

5.1.2 (2024-02-06)

Code Refactoring

  • improved dom-to-react, type (6630d01)

5.1.1 (2024-01-13)

Build System

  • deps: bump html-dom-parser from 5.0.6 to 5.0.7 (#1264) (521f7ad)

5.1.0 (2024-01-10)

Features

  • dom-to-react: pass index as 2nd argument to replace option (b27d30c), closes #1240

5.0.11 (2023-12-20)

Build System

  • deps: bump html-dom-parser from 5.0.5 to 5.0.6 (#1233) (0c70c12)

5.0.10 (2023-12-18)

Bug Fixes

  • esm: make ESM exports explicit in index.mjs and utilities.mjs (3e0fd2b)

5.0.9 (2023-12-18)

Bug Fixes

  • esm: fix ESM types by adding .mts declaration files (ce09a65)

5.0.8 (2023-12-18)

Build System

  • deps: bump html-dom-parser from 5.0.4 to 5.0.5 (#1221) (bdc69bf)

5.0.7 (2023-12-04)

Build System

  • deps: bump style-to-js from 1.1.9 to 1.1.10 (#1202) (1e18d9d)

5.0.6 (2023-11-03)

Build System

  • deps: bump style-to-js from 1.1.8 to 1.1.9 (#1151) (ec6aefc)

5.0.5 (2023-11-02)

Code Refactoring

  • improved attributes-to-props, dom-to-react, utilities (049f19a)

5.0.4 (2023-11-01)

Code Refactoring

  • type: improved attributes-to-props and utilities type (f65ba8d)

Build System

  • deps: bump html-dom-parser from 5.0.3 to 5.0.4 (#1141) (f5d9149)

5.0.3 (2023-10-30)

Bug Fixes

5.0.2 (2023-10-30)

Code Refactoring

  • domToReact: refactoring multiple types (8ef6201)

5.0.1 (2023-10-29)

Bug Fixes

  • dom-to-react: default props.children to undefined instead of null (a6978c3)
  • types: add back object to replace option return type (88eea66)

5.0.0 (2023-10-29)

⚠ BREAKING CHANGES

  • CommonJS imports require the .default key

Code Refactoring

4.2.10 (2023-10-28)

Build System

  • deps: bump html-dom-parser from 5.0.2 to 5.0.3 (#1108) (52f7615)

4.2.9 (2023-10-22)

Build System

  • package: bump react-property from 2.0.0 to 2.0.2 (665b30a)

4.2.8 (2023-10-21)

Miscellaneous Chores

  • utilities: remove unused function invertObject (7cc8df7)

4.2.7 (2023-10-20)

Bug Fixes

  • upgrade html-dom-parser and style-to-js to fix source map warnings (4469022)

4.2.6 (2023-10-19)

Build System

  • deps: bump style-to-js from 1.1.5 to 1.1.6 (#1092) (93206d3)

4.2.5 (2023-10-17)

Build System

  • deps: bump html-dom-parser from 5.0.0 to 5.0.1 (#1089) (27de2d3)
  • deps: bump style-to-js from 1.1.4 to 1.1.5 (#1090) (0946e8a)

4.2.4 (2023-10-17)

Build System

  • package: bump html-dom-parser from 4.0.1 to 5.0.0 (9fb888f)

4.2.3 (2023-10-16)

Build System

  • deps: bump html-dom-parser from 4.0.0 to 4.0.1 (#1081) (9e09066)

4.2.2 (2023-09-01)

Build System

  • deps: bump style-to-js from 1.1.3 to 1.1.4 (#1034) (7620daf)

4.2.1 (2023-08-09)

Bug Fixes

  • utilities: fix ELEMENTS_WITH_NO_TEXT_CHILDREN naming (9ec5ba1)

4.2.0 (2023-07-21)

Features

4.1.0 (2023-07-20)

Features

4.0.0 (2023-05-31)

⚠ BREAKING CHANGES

  • deps: bump html-dom-parser from 3.1.7 to 4.0.0

Build System

  • deps: bump html-dom-parser from 3.1.7 to 4.0.0 (99f02a7), closes #941

3.0.16 (2023-04-21)

Documentation

  • readme: bump version for README.md typo fixes (9f5ce94)

3.0.15 (2023-03-25)

Build System

  • package: bump html-dom-parser from 3.1.6 to 3.1.7 (ed585e2)

3.0.14 (2023-03-24)

Bug Fixes

  • types: fix "Type error: ',' expected." in index.d.ts (d9c608d), closes #871

3.0.13 (2023-03-22)

Bug Fixes

  • bump html-dom-parser to 3.1.6 to fix feGaussianBlur misspelling (81bfeba), closes #734

3.0.12 (2023-03-06)

Bug Fixes

3.0.11 (2023-03-04)

Bug Fixes

  • attributes-to-props: don't convert non-uncontrolled component props (76eab7c), closes #839

3.0.10 (2023-03-04)

Bug Fixes

3.0.9 (2023-02-11)

Bug Fixes

  • index: fix exports for UMD build (CDN script) (6225395), closes #828

3.0.8 (2023-01-17)

Bug Fixes

  • package: include types in exports to support TypeScript ESM node16 (39844c4)

Build System

  • package: bump html-dom-parser from 3.1.2 to 3.1.3 (bfe970a)
  • package: bump style-to-js from 1.1.2 to 1.1.3 (7cf5b99)

3.0.7 (2023-01-05)

Bug Fixes

  • attributes-to-props: don't convert value of option tag (#790) (bb4bf49)

3.0.6 (2022-12-25)

Build System

  • package: bump style-to-js from 1.1.1 to 1.1.2 (019f1bc)

3.0.5 (2022-12-25)

Bug Fixes

  • index: don't export unused domhandler class Node (7a9c207)
  • index: export domhandler classes (4fc3a73)

3.0.4 (2022-08-23)

Bug Fixes

  • package: upgrade html-dom-parser to fix client ES Module import (f6c982c), closes #662

3.0.3 (2022-08-20)

Bug Fixes

  • package: upgrade html-dom-parser to fix client ES Module export (415cb59)

3.0.2 (2022-08-19)

Build System

  • package: bump html-dom-parser from 3.0.1 to 3.1.0 (cf59e96), closes #655

3.0.1 (2022-07-10)

Bug Fixes

  • parse head/body with newline correctly (bump html-dom-parser) (d00087a)

3.0.0 (2022-07-05)

⚠ BREAKING CHANGES

  • bump domhandler from 4 to 5, html-dom-parser from 2 to 3

Build System

  • upgrade domhandler to 5.0.3 and html-dom-parser to 3.0.0 (a0f63a2)

2.0.0 (2022-06-18)

⚠ BREAKING CHANGES

  • package: remove Internet Explorer (IE) support

Build System

  • package: bump html-dom-parser from 1.2.0 to 2.0.0 (6eeb156)

1.4.14 (2022-05-30)

Bug Fixes

  • bump style-to-js to 1.1.1; don't capitalize ms vendor prefix (3df9a29)

1.4.13 (2022-05-27)

Bug Fixes

  • export domhandler' Element (095b6a2)

1.4.12 (2022-04-22)

Bug Fixes

  • package.json not defined by exports warning (4456f6a)

1.4.11 (2022-04-15)

Build System

  • upgrade html-dom-parser to add support for react-native (50eafcc)

1.4.10 (2022-03-30)

Build System

  • package: add support for React 18 (2816c53)

1.4.9 (2022-03-20)

Build System

1.4.8 (2022-02-06)

Bug Fixes

  • ensure backwards compatibility for html-dom-parser's ES Module (1d9ab19), closes #445

1.4.7 (2022-02-05)

Build System

  • package: upgrade html-dom-parser from 1.0.4 to 1.1.0 (750f5e6)

1.4.6 (2022-01-28)

Bug Fixes

1.4.5 (2022-01-05)

Bug Fixes

  • make reset and submit input types retain value attribs (b9613f4)

1.4.4 (2021-12-18)

Bug Fixes

  • dom-to-react: trim whitespaces if it is not valid in parent (523e292)
  • grammar and doc strings (87b0cd4)
  • improved language in README.md and removed TOC item (4126592)
  • remove #document from list of node names (d6e3554)

1.4.3 (2021-12-13)

Bug Fixes

  • attributes-to-props: convert attrib to uncontrolled component prop (6786046), closes #321

1.4.2 (2021-12-06)

Build System

  • deps: bump domhandler to 4.3.0 and html-dom-parser to 1.0.4 (2a9783b)

1.4.1 (2021-11-27)

Performance Improvements

  • upgrade dependency html-dom-parser to v1.0.3 (8987efb)

1.4.0 (2021-10-01)

Features

  • added CRA typescript example (42f42e5)
  • export domhandler's Element (0473e83)

1.3.0 (2021-09-07)

Features

  • upgrade react-property to get react-dom 17 DOM/SVG properties (f0fbbff)

1.2.9 (2021-09-06)

Build System

  • deps: bump domhandler from 4.2.0 to 4.2.2 (cac7ddf)
  • deps: bump html-dom-parser from 1.0.1 to 1.0.2 (72cccad)
  • deps: bump react-property from 1.0.1 to 1.0.2 (9feedd7)

1.2.8 (2021-08-12)

Bug Fixes

  • rename unit test per feedback (f39cf38)
  • utilities: skip corrupted style attributes (509486e), closes #256

1.2.7 (2021-06-19)

1.2.6 (2021-04-18)

Bug Fixes

  • attributes-to-props: correct attributes-to-props type Props (1bd1824), closes #242

1.2.5 (2021-04-13)

Bug Fixes

  • package: add domhandler to dependencies (88cb7ad), closes #240

1.2.4 (2021-02-01)

Bug Fixes

  • index: refactor ES module from ES6 to ES5 syntax (9112250), closes #222

1.2.3 (2021-01-28)

Bug Fixes

  • index: make sure to export the named exports (1689bd9), closes #217

1.2.2 (2021-01-28)

Bug Fixes

1.2.1 (2021-01-15)

Bug Fixes

  • package: add missing file (70cdb4c)

1.2.0 (2021-01-15)

Features

  • package: add es module entry point (ca0340a)

1.1.2 (2021-01-12)

Bug Fixes

  • index: include domhandler Node in DOMNode type (ac4aff3), closes #207

1.1.1 (2020-12-27)

Bug Fixes

1.1.0 (2020-12-26)

Features

  • index: export domhandler node types (dfa0c19)

1.0.0 (2020-12-14)

Build System

  • package: upgrade dependency html-dom-parser to 0.5.0 (5568ed7)

BREAKING CHANGES

  • package: upgrade dependency html-dom-parser to 0.5.0

0.14.3 (2020-12-12)

Bug Fixes

  • dom-to-react: transform style to object for Web Components (83efbce), closes #188

0.14.2 (2020-11-23)

0.14.1 (2020-11-03)

0.14.0 (2020-09-11)

Features

0.13.0 (2020-06-07)

Features

  • dom-to-react: add option trim that skips whitespace nodes (413eaa0)
  • index: type trim in HTMLReactParserOptions (be71b13)

0.12.0 (2020-06-04)

Features

  • index: add htmlparser2 type to HTMLReactParserOptions (81f74fb)
  • index: add options.htmlparser2 (c4ecf64)

0.11.1 (2020-06-03)

Performance Improvements

  • index: return empty array if first argument is empty string (7f61f97)

0.11.0 (2020-06-02)

Features

0.10.5 (2020-05-26)

Tests

  • html-to-react: tidy and organize tests in html-to-react.js (8dfbfe0)

Build System

  • package: add missing peerDependency typescript (91fb693)
  • package: upgrade devDependencies (b2dc83b)
  • rollup: upgrade rollup, consolidate config, remove cross-env (55b2b4e)

0.10.4 (2020-05-25)

Tests

  • attributes-to-props: test that CSS comment is not parsed (0c27987)
  • dom-to-react: tidy tests and add case for single node replace (452f6be)
  • tidy tests, replace assert.equal with assert.strictEqual (ef04eff)

0.10.3 (2020-03-28)

Bug Fixes

  • update .d.ts docstrings (bae05c0)
  • use JSX.Element for type definitions (d8e2ada)

0.10.2 (2020-03-13)

Bug Fixes

  • index: add default export for parser (6259959)

Tests

  • html-to-react: add test to ensure default export for parser (efba1d4)
  • html-to-react: have a stronger assert (064f0df)

0.10.1 (2020-02-08)

Bug Fixes

  • index: make replace property optional in index.d.ts (801512b), closes #134

0.10.0 (2019-11-09)

Build System

Features

  • dom-to-react: support Preact (c3e77bb)

Tests

  • types: move TypeScript tests from lint to test directory (7c9ab9d)

0.9.2 (2019-11-04)

Bug Fixes

  • refactor TypeScript declaration file for index.d.ts (f1fc00b)

Build System

0.9.1 (2019-07-09)

Build System

  • replace webpack with rollup in order to optimize bundle (a04ef27)
  • index: fix rollup error of mixing named and default exports (230de70)

0.9.0 (2019-07-09)

Bug Fixes

  • attributes-to-props: handle attr named after Object properties (3f857bb)

Build System

  • package: update react-property to 1.0.1 (26ebef9)

Features

  • attributes-to-props: check for overloaded boolean values (1151cfb)
  • attributes-to-props: replace react-dom with react-property (d6274b9), closes #107

Tests

  • attributes-to-props: improve test names (17fbdfd)

0.8.1 (2019-07-03)

Tests

  • html-to-react: update variable name to fix test (73237dd)

0.8.0 (2019-06-24)

Bug Fixes

  • attributes-to-props: fix lint error no-prototype-builtins (fa66dfc)

Build System

  • package: refactor webpack config and generate sourcemap (5dd4f07)
  • package: rename npm script cover to test:cover (7d806c8)
  • package: update `html-dom-parser@0.2.2` and devDependencies (b39ac53)
  • package: update dependencies and devDependencies (8765ea9)
  • package: update dependency style-to-object to 0.2.3 (c2cc2ec)

Features

  • dom-to-react: skip and do not parse <script> content (1fb5ee2)

Tests

  • html-to-react: add test that verifies domToReact is exported (320c364)
  • verify invalid style for attributesToProps throws an error (b97f2e1)

0.7.1 (2019-05-27)

0.7.0 (2019-04-05)

Bug Fixes

  • coveralls: moved dtslint tests to lint folder (306fceb)
  • types: html-dom-parser > html-react-parser (438b9af)

Features

  • types: add lib/dom-to-react declaration (27ed8b6)

0.6.4 (2019-03-29)

Bug Fixes

  • dom-to-react: allow custom keys for replacement (abf20a2)
  • dom-to-react: fix typos in the test (4eec53e)

0.6.3 (2019-03-19)

Bug Fixes

  • typescript: test.tsx after dtslint run (38e6bba)

0.6.2 (2019-03-07)

0.6.1 (2019-01-03)

Bug Fixes

  • utilities: allow numbers in custom style names (5a6600f)

0.6.0 (2018-12-17)

Features

  • utilities: add support for custom styles beginning with "--*" (2c0a9dc)

0.5.0 (2018-12-16)

Bug Fixes

  • attributes-to-props: undo default function parameter (1017b25)

Features

  • support custom elements in React 16 (7b2c5a8)

0.4.7 (2018-09-14)

0.4.6 (2018-05-13)

Bug Fixes

  • accidentally left a console (953e564)
  • added test case for viewBox (261ffb7)
  • moving svg mock to correct place (6ffb148)
  • svg attributes now correctly handled (94643e1)

0.4.5 (2018-05-09)

Bug Fixes

0.4.4 (2018-05-07)

Bug Fixes

0.4.3 (2018-03-27)

Bug Fixes

  • parser: fix boolean attributes parsing (e478a44)
  • parser: fix case when style is empty string (fa2a8b4)

0.4.2 (2018-02-20)

Bug Fixes

0.4.1 (2017-11-28)

Bug Fixes

  • attributes-to-props.js: Remove unappropriate console logging and remove double quote from tests (10ff149)
  • attributes-to-props.js: Use AST to transform style attributes into an style object (68cd565)
  • utilities.js: Format string to lowercase before converting to camel case and assert the string is a string (4522666)

0.4.0 (2017-10-01)

Added

  • react-dom-core to dependencies (closes #43)
    • react-dom 16 no longer exposes lib, which includes the DOM property configs
    • Upgrade devDependencies of react and react-dom to 16
    • Update README and examples

0.3.6 (2017-09-30)

Changed

  • Dependencies
    • html-dom-parser@0.1.2
      • Fixes IE9 client parser bug
    • Set react and react-dom versions to ^15.4
      • Version 16 no longer exposes HTMLDOMPropertyConfig and SVGDOMPropertyConfig

0.3.5 (2017-06-26)

Changed

0.3.4 (2017-06-17)

Changed

Removed

  • Dependencies:
    • jsdomify

0.3.3 (2017-01-27)

Added

  • Created CHANGELOG with details on each version release (#37)

Changed

  • Update examples to load parser from relative dist/ directory (#36)
  • Removed unnecessary field "browser" in package.json (#36)

0.3.2 (2017-01-26)

Fixed

  • Decode HTML entities by default on node (#34)

0.3.1 (2017-01-10)

Changed

  • Updated README by fixing CDN installation instructions and adding JSFiddle

0.3.0 (2016-11-18)

Changed

  • Upgrade react and react-dom to >15.4

0.2.0 (2016-11-18)

Added

  • Create npm script clean that removes dist/ directory

Fixed

  • Silence webpack warning by keeping react <15.4 in this version

0.1.1 (2016-11-17)

Fixed

  • HTMLDOMPropertyConfig.js and SVGDOMPropertyConfig.js have been moved from react/lib/ to react-dom/lib/ in v15.4

0.1.0 (2016-10-14)

Changed

  • Replace HTML to DOM converter with html-dom-parser (#28)
    • Save html-dom-parser
    • Remove domhandler and htmlparser2
  • Update tests and README

0.0.7 (2016-09-27)

Added

  • Examples of using the parser with script tag and RequireJS (#26)

Changed

  • Update build (#25)
  • Update README description, instructions, and examples (#27)

0.0.6 (2016-09-27)

Added

  • README example with advanced usage of replace option from @poacher2k (#17)
  • Contributors section to README (#21)

Changed

  • Use webpack to build UMD bundle (#22)

Fixed

  • Regex bug on client parser (#24)

0.0.5 (2016-08-30)

Changed

  • Remove key parameter from replace and use React.cloneElement (#18)

Fixed

  • Parsing of <script> and <style> tags (#20)

0.0.4 (2016-08-29)

Added

  • Send coverage report generated by istanbul to coveralls (#12)
  • Display badges in README (#13, #15)
  • Update parser's replace option with additional 2nd parameter key (#16)

Fixed

  • Void elements (e.g., <img />) should not have children (#16)
  • Set default key parameter for sibling elements due to keys warning (#16)

0.0.3 (2016-08-24)

Added

  • Make package UMD compatible (#9)
  • Throw an error if first argument is not a string (#10)

Changed

  • Differentiate between node and browser environments for parser (#5)

Fixed

  • HTML to DOM conversion on the client (#10)

0.0.2 (2016-08-23)

Added

Fixed

  • package.json peerDependencies for react and react-dom

0.0.1 (2016-08-23)

Added

  • HTML to React parser which consists of:
    • HTML string to DOM object converter
    • DOM object to React nodes converter
  • Tests
  • README