Skip to content

Commit

Permalink
Improve style - replace forEach by map
Browse files Browse the repository at this point in the history
  • Loading branch information
coyotte508 committed Apr 6, 2018
1 parent 05f7f53 commit a241073
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions src/lexers/jsx-lexer.js
Original file line number Diff line number Diff line change
Expand Up @@ -89,20 +89,20 @@ export default class JsxLexer extends HTMLLexer {
* @param {string} originalString The original string being parsed
*/
parseAcornPayload(children, originalString) {
children.forEach((child, i) => {
children = children.map(child => {
switch (child.type) {
case 'JSXText': children[i] = {
case 'JSXText': return {
type: 'text',
content: child.value.replace(/^(?:\s*(\n|\r)\s*)?(.*)(?:\s*(\n|\r)\s*)?$/, '$2')
}; break
case 'JSXElement': children[i] = {
};
case 'JSXElement': return {
type: 'tag',
children: this.parseAcornPayload(child.children, originalString)
}; break;
case 'JSXExpressionContainer': children[i] = {
};
case 'JSXExpressionContainer': return {
type: 'js',
content: originalString.slice(child.start, child.end)
}; break;
};
default: throw new ParsingError("Unknown ast element when parsing jsx: " + child.type)
}
});
Expand Down

0 comments on commit a241073

Please sign in to comment.