| 2257 | } |
| 2258 | |
| 2259 | function appendChild(children, child) { |
| 2260 | var lastChild = children[children.length - 1]; |
| 2261 | if (child.type === "element" && !child.tag.fresh && lastChild && lastChild.type === "element" && child.tag.matchesElement(lastChild.tag)) { |
| 2262 | if (child.tag.separator) { |
| 2263 | appendChild(lastChild.children, ast.text(child.tag.separator)); |
| 2264 | } |
| 2265 | child.children.forEach(function(grandChild) { |
| 2266 | // Mutation is fine since simplifying elements create a copy of the children. |
| 2267 | appendChild(lastChild.children, grandChild); |
| 2268 | }); |
| 2269 | } else { |
| 2270 | children.push(child); |
| 2271 | } |
| 2272 | } |
| 2273 | |
| 2274 | function removeEmpty(nodes) { |
| 2275 | return flatMap(nodes, function(node) { |