Skip to content

Commit

Permalink
[Fix] no-adjacent-inline-elements: prevent crash on nullish children
Browse files Browse the repository at this point in the history
Fixes #2620
  • Loading branch information
Rogdham authored and ljharb committed Apr 10, 2020
1 parent 80f3826 commit 78ddd46
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 0 deletions.
3 changes: 3 additions & 0 deletions lib/rules/no-adjacent-inline-elements.js
Expand Up @@ -84,6 +84,9 @@ module.exports = {
function validate(node, children) {
let currentIsInline = false;
let previousIsInline = false;
if (!children) {
return;
}
for (let i = 0; i < children.length; i++) {
currentIsInline = isInline(children[i]);
if (previousIsInline && currentIsInline) {
Expand Down
4 changes: 4 additions & 0 deletions tests/lib/rules/no-adjacent-inline-elements.js
Expand Up @@ -69,6 +69,10 @@ ruleTester.run('no-adjacent-inline-elements', rule, {
code: '<div><a></a> some text <a></a></div>;',
parserOptions
},
{
code: 'React.createElement("div", null, "some text");',
parserOptions
},
{
code: ('React.createElement("div", undefined, [React.createElement("a"), ' +
'" some text ", React.createElement("a")]);'),
Expand Down

0 comments on commit 78ddd46

Please sign in to comment.