()
| 97 | } |
| 98 | |
| 99 | private performRender() { |
| 100 | const parsedOptions = this.parsedOptions; |
| 101 | if (!isCompleteParsedInfographicOptions(parsedOptions)) { |
| 102 | this.emitter.emit('error', new Error('Incomplete options')); |
| 103 | return; |
| 104 | } |
| 105 | |
| 106 | const { container } = this.parsedOptions; |
| 107 | const template = this.compose(parsedOptions); |
| 108 | const renderer = new Renderer(parsedOptions, template); |
| 109 | this.node = renderer.render(); |
| 110 | container?.replaceChildren(this.node); |
| 111 | this.editor?.destroy(); |
| 112 | this.editor = undefined; |
| 113 | if (this.options.editable) { |
| 114 | this.editor = new Editor(this.emitter, this.node, parsedOptions); |
| 115 | } |
| 116 | |
| 117 | this.rendered = true; |
| 118 | this.emitter.emit('rendered', { node: this.node, options: this.options }); |
| 119 | const currentNode = this.node; |
| 120 | if (currentNode) { |
| 121 | void waitForSvgLoads(currentNode).then(() => { |
| 122 | if (this.node !== currentNode) return; |
| 123 | this.emitter.emit('loaded', { |
| 124 | node: currentNode, |
| 125 | options: this.options, |
| 126 | }); |
| 127 | }); |
| 128 | } |
| 129 | return true; |
| 130 | } |
| 131 | |
| 132 | /** |
| 133 | * Compose the SVG template |
no test coverage detected