* Appends the given element to a layer. If the layer does not exist, it is * created. * * @internal
(elem: IRenderedElement, layerNum: number)
| 146 | * @internal |
| 147 | */ |
| 148 | append(elem: IRenderedElement, layerNum: number) { |
| 149 | if (!this.layers.has(layerNum)) { |
| 150 | this.createLayer(layerNum); |
| 151 | } |
| 152 | const childElem = elem.getSvgRoot(); |
| 153 | if (this.layers.get(layerNum)?.lastChild !== childElem) { |
| 154 | // Only append the child if it isn't already last (to avoid re-firing |
| 155 | // events like focused). |
| 156 | this.layers.get(layerNum)?.appendChild(childElem); |
| 157 | } |
| 158 | } |
| 159 | |
| 160 | /** |
| 161 | * Creates a layer and inserts it at the proper place given the layer number. |