()
| 38 | } |
| 39 | |
| 40 | public stringify(): string { |
| 41 | if (!this.attr.id) { |
| 42 | this.attr.id = `_${(++counter).toString(36)}`; |
| 43 | } |
| 44 | const attr = Object.entries(this.attr) |
| 45 | .map( |
| 46 | ([key, value]) => |
| 47 | `${key}="${escape(Array.isArray(value) ? value.join(" ") : value.toString())}"`, |
| 48 | ) |
| 49 | .join(" "); |
| 50 | const children = this.children?.map((child) => child.stringify()).join("") || ""; |
| 51 | return this.single |
| 52 | ? `<${this.type} ${attr} />` |
| 53 | : `<${this.type} ${attr}>${this.content ? escape(this.content) : ""}${children}</${this.type}>`; |
| 54 | } |
| 55 | |
| 56 | public css(): string { |
| 57 | if (!this.attr.id) { |
no test coverage detected