Skip to content

Fix error thrown when invalid html for lists#273

Merged
jsdf merged 1 commit intojsdf:masterfrom
lukejsimonetti:master
Jul 25, 2020
Merged

Fix error thrown when invalid html for lists#273
jsdf merged 1 commit intojsdf:masterfrom
lukejsimonetti:master

Conversation

@lukejsimonetti
Copy link
Contributor

Currently if invalid markup for Lists/List Items is passed to the component, an uncaught error is thrown and it doesn't die gracefully. The code assumes that all <li> nodes have a parent <ul>. With this assumption, the code attempts to check the parent's name: parent.name. If invalid markup is passed, parent is undefined, so the uncaught error reads "TypeError: Cannot read property 'name' of undefined"

Invalid markup that will make it crash:
<li> <ul> <li>Fine & Visual Art</li> <li>Vocal Music</li> <li>Instrumental</li> </ul>

Since we cannot assume the correct markup in this scenario, this fix will ignore <li> without a parent node and won't render anything.

P.S. This is my first react-native commit, so please let me know if I can improve upon anything. Thanks!

@jsdf jsdf merged commit e81c988 into jsdf:master Jul 25, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants