TheKnarf / isomorphic-jsx

A JSX-powered templating library for building multi page websites.
MIT License
13 stars 2 forks source link

Sometimes you get ',' between dom elements #1

Closed TheKnarf closed 6 years ago

TheKnarf commented 6 years ago
TheKnarf commented 6 years ago
    return `<${type}${attr}>${children.join('')}</${type}>`;

https://github.com/TheKnarf/isomorphic-jsx/blob/master/src/index.js#L28

Here children.join("") should not generate , between the elements, unless the children array contains arrays inside itself. That might happen, we need to find a test case for it. If that's the case we might need some recursive function for handling those cases.

TheKnarf commented 6 years ago

Wrote a recursive flattening function which fixes the problem:

const flatten = arr =>
    Array.isArray(arr)
        ? arr.map(flatten).join('')
        : arr;

Fixed in 7862bd30a1cb14138c37e4f94b87088a79e631cd