-
-
Notifications
You must be signed in to change notification settings - Fork 136
Open
Labels
questionFurther information is requestedFurther information is requestedwontfixThis will not be worked onThis will not be worked on
Description
Expected Behavior
domNode instanceof Element should be true
Actual Behavior
domNode instanceof Element is false
Steps to Reproduce
After upgrading from version 1.4 to 3.0 domNode instanceof Element is suddenly returning false
Reproducible Demo
import parse, { HTMLReactParserOptions, domToReact, Element, DOMNode } from 'html-react-parser';
import React, { FC } from 'react';
const Textblock: FC = () => {
const htmlFromCMS = '<h1>Weird</h1><p>dsdsdsdsdsd</p>';
const options: HTMLReactParserOptions = {
trim: true,
replace: (domNode) => {
console.log(domNode instanceof Element);
console.log('/******************************************************************/');
if (domNode instanceof Element && domNode.attribs && domNode.type === 'tag') {
switch (domNode.name) {
case 'h1':
return (
<h1 className="sydb-textblock__heading sydb-textblock__heading--h1">
{domToReact(domNode.children, options)}
</h1>
);
case 'h2':
return (
<h2 className="sydb-textblock__heading sydb-textblock__heading--h2">
{domToReact(domNode.children, options)}
</h2>
);
case 'p':
return (
<p className="test">
{domToReact(domNode.children, options)}
</p>
);
}
}
},
};
return (
<article>
{parse(htmlFromCMS, options)}
</article>
);
};
export default Textblock;
What could have happend?
Environment
- Version: 3.0.1
- Platform: Next.js
- Browser: Chrome
tremby, ahuss-ntt, jonmhutch7, charkour, tandat2209 and 6 morejlegreid
Metadata
Metadata
Assignees
Labels
questionFurther information is requestedFurther information is requestedwontfixThis will not be worked onThis will not be worked on