Sha256: 5b77138f8f1906feb21e3f5013e752382723e625f0f5eaaaf90d6df68ca8ca96
Contents?: true
Size: 567 Bytes
Versions: 4
Compression:
Stored size: 567 Bytes
Contents
import Node from '../Node.js'; function containsNewLine(node) { return ( node.type === 'JSXText' && !/\S/.test(node.value) && /\n/.test(node.value) ); } export default class JSXClosingFragment extends Node { transpile(code) { let spaceBeforeParen = true; const lastChild = this.parent.children[this.parent.children.length - 1]; // omit space before closing paren if this is on a separate line if (lastChild && containsNewLine(lastChild)) { spaceBeforeParen = false; } code.overwrite(this.start, this.end, spaceBeforeParen ? ' )' : ')'); } }
Version data entries
4 entries across 4 versions & 1 rubygems