Comments (10)
Also I have noticed that contentScriptType and contentStyleType in the SVG tag are being replaced with lower case version which results in this warning in the browser:
index.js:2178 Warning: Invalid DOM property contentscripttype
. Did you mean contentScriptType
?
in svg (created by Coach)
in div (created by Paper)
in Paper (created by WithStyles(Paper))
in WithStyles(Paper) (at coach.js:148)
in Coach (created by WithStyles(Coach))
in WithStyles(Coach) (created by Route)
in Route (at App.js:109)
in div (at App.js:80)
in div (at App.js:63)
in Router (created by BrowserRouter)
in BrowserRouter (at App.js:61)
in App (at src/index.js:7)
from html-react-parser.
Looking a little deeper I am pretty sure that (var x=0;x<ids.length;x++) is causing the problem. It looks like the parser is dying when its hits the <
Since the script tag's content is in a CDATA element, it should not have a problem with this.
I've also tried react-render-html which has the exact same problem, so my assumption is that the problem is in one of the dependencies.
from html-react-parser.
@ianbale Can you help me reproduce the error you're seeing with JSFiddle or CodeSandbox?
from html-react-parser.
I was able to reproduce the issue. To fix the errors, I had to do 2 things:
- Remove
CDATA
in the markup as that's the cause of the unexpected end of input error - Change
'</script>'
to'</scr' + 'ipt>
to resolve unterminated string constant error
The invalid DOM property warnings are still there (expected since the parser lowercases attributes that aren't part of the react-dom
whitelist. (The warning, although annoying, is fine since the svg should still render.)
See fiddle.
from html-react-parser.
Since the script is essential, rendering without it is not really an option, neither is changing the input SVG.
Surely the parser should handle CDATA since it's a perfectly valid within the XML?
For now I'm just using dangerouslySetInnerHTML which works perfectly. Since it's a private app with trusted SVG data that is not a problem for me.
from html-react-parser.
Gotcha. Technically, the parser should handle the CDATA but it seems like it didn't in my example. I think using dangerouslySetInnerHTML
should be fine in your use case.
If the issue is resolved on your end, do you mind closing it?
from html-react-parser.
I could... but having decided to use dangerouslySetInnerHTML before I even reported the issue to you, the whole point of doing so was to give you the heads up so this issue, which is bound to affect someone else at some point, could be resolved.
As I mentioned, I think it is likely that the fault does not lie in html-react-parser, but rather in one your of dependencies. It might be nice if you could locate the offending one and pass the issue onto them rather then just closing this one...
I'm happy to do that if you can tell me which one is causing the problem?
from html-react-parser.
I understand and appreciate your sentiment. The bug may be coming from html-dom-parser
.
It would be nice to create a simplified test case that reproduces this bug in the other package.
from html-react-parser.
Thanks. I'll raise an issue there as soon as I have a few spare minutes.
from html-react-parser.
Closing issue due to inactivity. Feel free to reopen if there are new updates.
from html-react-parser.
Related Issues (20)
- If the htmlString is dynamic and contains custom components (with hooks used), an error will be hanpend HOT 1
- missing type for domNode.children HOT 4
- Issue after 5.0.9 update HOT 3
- Cannot Handle Microsoft Meeting Link HOT 3
- Add Current Node Index in `replace` Callback HOT 6
- Replacing domNode with editor element multiple times breaks editor bubble menu HOT 4
- Method transform has wrong current index HOT 5
- Validate props beforing passing the props object to the element HOT 3
- SVG html with large Data URL returns empty SVG code HOT 2
- Importing the lib with a very large size HOT 2
- How to resize/style the HTML content? HOT 11
- important style is not parsed HOT 13
- Resolution error when using TypeScript with `moduleResolution` set to `node16` or `nodenext` HOT 3
- How to keep a specific element from being transformed by React? HOT 2
- Type of `parse` is `any` HOT 2
- Version 5.1.5 - multiple versions of @types/react causes typescript build errors HOT 6
- Incompatible default exports between ESM and CJS HOT 5
- domNode to HTML string? HOT 2
- Usage in web worker HOT 9
- String text with less than greater than sign are treated as tags. (eg. 4<y<8) HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from html-react-parser.