Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -614,9 +614,9 @@ npm run benchmark
Output of benchmark run on MacBook Pro 2024:

```
html-to-react - Single x 1,230,874 ops/sec ±0.21% (97 runs sampled)
html-to-react - Multiple x 502,028 ops/sec ±0.89% (94 runs sampled)
html-to-react - Complex x 54,401 ops/sec ±0.76% (93 runs sampled)
html-to-react - Single x 1,270,990 ops/sec ±0.21% (100 runs sampled)
html-to-react - Multiple x 522,472 ops/sec ±0.64% (94 runs sampled)
html-to-react - Complex x 54,028 ops/sec ±0.82% (98 runs sampled)
```

Run [Size Limit](https://github.com/ai/size-limit):
Expand Down
26 changes: 13 additions & 13 deletions __tests__/__snapshots__/dom-to-react.test.tsx.snap
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
// Jest Snapshot v1, https://jestjs.io/docs/snapshot-testing
// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html

exports[`domToReact converts <textarea> correctly 1`] = `
exports[`domToReact > converts <textarea> correctly 1`] = `
<textarea
defaultValue="foo"
/>
`;

exports[`domToReact converts LaTeX 1`] = `
exports[`domToReact > converts LaTeX 1`] = `
[
<span
className="math"
Expand All @@ -18,7 +18,7 @@ exports[`domToReact converts LaTeX 1`] = `
]
`;

exports[`domToReact converts SVG element with viewBox attribute 1`] = `
exports[`domToReact > converts SVG element with viewBox attribute 1`] = `
<svg
id="foo"
viewBox="0 0 512 512"
Expand All @@ -27,7 +27,7 @@ exports[`domToReact converts SVG element with viewBox attribute 1`] = `
</svg>
`;

exports[`domToReact converts custom element with attributes 1`] = `
exports[`domToReact > converts custom element with attributes 1`] = `
<custom-element
class="myClass"
custom-attribute="value"
Expand All @@ -40,7 +40,7 @@ exports[`domToReact converts custom element with attributes 1`] = `
/>
`;

exports[`domToReact converts multiple DOM nodes to React 1`] = `
exports[`domToReact > converts multiple DOM nodes to React 1`] = `
[
<p>
foo
Expand All @@ -51,13 +51,13 @@ exports[`domToReact converts multiple DOM nodes to React 1`] = `
]
`;

exports[`domToReact converts single DOM node to React 1`] = `
exports[`domToReact > converts single DOM node to React 1`] = `
<p>
foo
</p>
`;

exports[`domToReact does not escape <script> content 1`] = `
exports[`domToReact > does not escape <script> content 1`] = `
<script
dangerouslySetInnerHTML={
{
Expand All @@ -67,7 +67,7 @@ exports[`domToReact does not escape <script> content 1`] = `
/>
`;

exports[`domToReact does not escape <style> content 1`] = `
exports[`domToReact > does not escape <style> content 1`] = `
<style
dangerouslySetInnerHTML={
{
Expand All @@ -77,7 +77,7 @@ exports[`domToReact does not escape <style> content 1`] = `
/>
`;

exports[`domToReact skips doctype and comments 1`] = `
exports[`domToReact > skips doctype and comments 1`] = `
[
<p>
foo
Expand All @@ -88,7 +88,7 @@ exports[`domToReact skips doctype and comments 1`] = `
]
`;

exports[`domToReact when React <16 removes unknown attributes 1`] = `
exports[`domToReact > when React <16 > removes unknown attributes 1`] = `
<custom-element
className="myClass"
style={
Expand All @@ -100,7 +100,7 @@ exports[`domToReact when React <16 removes unknown attributes 1`] = `
/>
`;

exports[`domToReact when React >=16 preserves unknown attributes 1`] = `
exports[`domToReact > when React >=16 > preserves unknown attributes 1`] = `
<custom-element
class="myClass"
custom-attribute="value"
Expand All @@ -113,7 +113,7 @@ exports[`domToReact when React >=16 preserves unknown attributes 1`] = `
/>
`;

exports[`transform option can wrap all elements 1`] = `
exports[`transform option > can wrap all elements 1`] = `
<div>
<ol>
<div>
Expand Down
44 changes: 22 additions & 22 deletions __tests__/__snapshots__/index.test.tsx.snap
Original file line number Diff line number Diff line change
@@ -1,28 +1,28 @@
// Jest Snapshot v1, https://jestjs.io/docs/snapshot-testing
// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html

exports[`HTMLReactParser escapes tags inside of <title> 1`] = `
exports[`HTMLReactParser > escapes tags inside of <title> 1`] = `
<title>
&lt;em&gt;text&lt;/em&gt;
</title>
`;

exports[`HTMLReactParser parses HTML with newlines 1`] = `
exports[`HTMLReactParser > parses HTML with newlines 1`] = `
[
"
",
<br />,
]
`;

exports[`HTMLReactParser parses HTML with newlines 2`] = `
exports[`HTMLReactParser > parses HTML with newlines 2`] = `
[
<br />,
"
",
]
`;

exports[`HTMLReactParser parses HTML with newlines 3`] = `
exports[`HTMLReactParser > parses HTML with newlines 3`] = `
[
"
",
Expand All @@ -32,14 +32,14 @@ exports[`HTMLReactParser parses HTML with newlines 3`] = `
]
`;

exports[`HTMLReactParser parses HTML with newlines 4`] = `
exports[`HTMLReactParser > parses HTML with newlines 4`] = `
<p>
foo
bar
</p>
`;

exports[`HTMLReactParser parses HTML with newlines 5`] = `
exports[`HTMLReactParser > parses HTML with newlines 5`] = `
[
<p>
foo
Expand All @@ -49,7 +49,7 @@ bar",
]
`;

exports[`HTMLReactParser parses HTML with newlines 6`] = `
exports[`HTMLReactParser > parses HTML with newlines 6`] = `
[
"foo",
<p>
Expand All @@ -62,7 +62,7 @@ bar
]
`;

exports[`HTMLReactParser parses SVG 1`] = `
exports[`HTMLReactParser > parses SVG 1`] = `
<svg
height="400"
width="450"
Expand Down Expand Up @@ -105,7 +105,7 @@ exports[`HTMLReactParser parses SVG 1`] = `
</svg>
`;

exports[`HTMLReactParser parses complex HTML with doctype 1`] = `
exports[`HTMLReactParser > parses complex HTML with doctype 1`] = `
<html>
<head>
<meta
Expand Down Expand Up @@ -162,19 +162,19 @@ exports[`HTMLReactParser parses complex HTML with doctype 1`] = `
</html>
`;

exports[`HTMLReactParser parses empty <script> 1`] = `<script />`;
exports[`HTMLReactParser > parses empty <script> 1`] = `<script />`;

exports[`HTMLReactParser parses empty <style> 1`] = `<style />`;
exports[`HTMLReactParser > parses empty <style> 1`] = `<style />`;

exports[`HTMLReactParser parses form 1`] = `
exports[`HTMLReactParser > parses form 1`] = `
<input
defaultChecked={true}
defaultValue="foo"
type="text"
/>
`;

exports[`HTMLReactParser parses list 1`] = `
exports[`HTMLReactParser > parses list 1`] = `
<ol>
<li>
One
Expand All @@ -187,7 +187,7 @@ exports[`HTMLReactParser parses list 1`] = `
</ol>
`;

exports[`HTMLReactParser parses multiple HTML elements 1`] = `
exports[`HTMLReactParser > parses multiple HTML elements 1`] = `
[
<p>
foo
Expand All @@ -198,19 +198,19 @@ exports[`HTMLReactParser parses multiple HTML elements 1`] = `
]
`;

exports[`HTMLReactParser parses single HTML element 1`] = `
exports[`HTMLReactParser > parses single HTML element 1`] = `
<p>
foo
</p>
`;

exports[`HTMLReactParser parses single HTML element with comment 1`] = `
exports[`HTMLReactParser > parses single HTML element with comment 1`] = `
<p>
foo
</p>
`;

exports[`HTMLReactParser parses template 1`] = `
exports[`HTMLReactParser > parses template 1`] = `
<template>
<article>
<p>
Expand All @@ -220,14 +220,14 @@ exports[`HTMLReactParser parses template 1`] = `
</template>
`;

exports[`htmlparser2 option parses XHTML with xmlMode enabled 1`] = `
exports[`htmlparser2 option > parses XHTML with xmlMode enabled 1`] = `
<ul>
<li />
<li />
</ul>
`;

exports[`replace option does not replace the element if an invalid React element is returned 1`] = `
exports[`replace option > does not replace the element if an invalid React element is returned 1`] = `
<html>
<head>
<meta
Expand Down Expand Up @@ -284,7 +284,7 @@ exports[`replace option does not replace the element if an invalid React element
</html>
`;

exports[`replace option replaces the element if a valid React element is returned 1`] = `
exports[`replace option > replaces the element if a valid React element is returned 1`] = `
<html>
<head>
<meta
Expand Down Expand Up @@ -341,7 +341,7 @@ exports[`replace option replaces the element if a valid React element is returne
</html>
`;

exports[`trim option preserves whitespace text nodes when disabled if valid in parent (default) 1`] = `
exports[`trim option > preserves whitespace text nodes when disabled if valid in parent (default) 1`] = `
<table>
<tbody>
<tr>
Expand Down
9 changes: 4 additions & 5 deletions __tests__/attributes-to-props.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -355,17 +355,16 @@ describe('attributesToProps with custom attribute', () => {
});

describe('utilities.PRESERVE_CUSTOM_ATTRIBUTES=false', () => {
const { PRESERVE_CUSTOM_ATTRIBUTES } = utilities;
const emptyProps = {};

beforeAll(() => {
// @ts-expect-error Cannot assign to 'PRESERVE_CUSTOM_ATTRIBUTES' because it is a read-only property.
utilities.PRESERVE_CUSTOM_ATTRIBUTES = false;
vi.spyOn(utilities, 'PRESERVE_CUSTOM_ATTRIBUTES', 'get').mockReturnValue(
false,
);
});

afterAll(() => {
// @ts-expect-error Cannot assign to 'PRESERVE_CUSTOM_ATTRIBUTES' because it is a read-only property.
utilities.PRESERVE_CUSTOM_ATTRIBUTES = PRESERVE_CUSTOM_ATTRIBUTES;
vi.restoreAllMocks();
});

it('omits unknown attributes', () => {
Expand Down
10 changes: 4 additions & 6 deletions __tests__/dom-to-react.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -211,16 +211,14 @@ describe('domToReact', () => {
});

describe('when React <16', () => {
const { PRESERVE_CUSTOM_ATTRIBUTES } = utilities;

beforeAll(() => {
// @ts-expect-error Cannot assign to 'PRESERVE_CUSTOM_ATTRIBUTES' because it is a read-only property.
utilities.PRESERVE_CUSTOM_ATTRIBUTES = false;
vi.spyOn(utilities, 'PRESERVE_CUSTOM_ATTRIBUTES', 'get').mockReturnValue(
false,
);
});

afterAll(() => {
// @ts-expect-error Cannot assign to 'PRESERVE_CUSTOM_ATTRIBUTES' because it is a read-only property.
utilities.PRESERVE_CUSTOM_ATTRIBUTES = PRESERVE_CUSTOM_ATTRIBUTES;
vi.restoreAllMocks();
});

it('removes unknown attributes', () => {
Expand Down
2 changes: 1 addition & 1 deletion eslint.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,8 @@ export default defineConfig([
languageOptions: {
globals: {
...globals.browser,
...globals.jest,
...globals.node,
...globals.vitest,
},
parserOptions: {
project: ['tsconfig.build.json', 'tsconfig.test.json'],
Expand Down
33 changes: 0 additions & 33 deletions jest.config.ts

This file was deleted.

Loading
Loading