| 6 | } |
| 7 | |
| 8 | toString(indent = 1, depth = 0) { |
| 9 | const props = Object.entries(this.props).map(([key, value]) => { |
| 10 | if (value === undefined) { |
| 11 | return key; |
| 12 | } |
| 13 | return `${key}="${value}"`; |
| 14 | }); |
| 15 | |
| 16 | const propsString = props.length > 0 ? ` ${props.join(' ')}` : ''; |
| 17 | |
| 18 | const indents = Array(indent * depth) |
| 19 | .fill('\t') |
| 20 | .join(''); |
| 21 | |
| 22 | const childrenString = this.childrenToString(indent, depth); |
| 23 | |
| 24 | return `${indents}<${this.name}${propsString}>\n${childrenString}\n${indents}</${this.name}>`; |
| 25 | } |
| 26 | |
| 27 | childrenToString(indent, depth) { |
| 28 | const childStrings = []; |