|
@@ -30,6 +30,18 @@ export abstract class VexFlowBackend {
|
|
|
return this.canvas;
|
|
|
}
|
|
|
|
|
|
+ public getRenderElement(): HTMLElement {
|
|
|
+ //console.log("backend type: " + this.getVexflowBackendType());
|
|
|
+ let renderingHtmlElement: HTMLElement = this.canvas; // for SVGBackend
|
|
|
+ if (this.getVexflowBackendType() === Vex.Flow.Renderer.Backends.CANVAS) {
|
|
|
+ renderingHtmlElement = this.inner;
|
|
|
+ // usage in removeFromContainer:
|
|
|
+ // for SVG, this.canvas === this.inner, but for Canvas, removing this.canvas causes an error because it's not a child of container,
|
|
|
+ // so we have to remove this.inner instead.
|
|
|
+ }
|
|
|
+ return renderingHtmlElement;
|
|
|
+ }
|
|
|
+
|
|
|
public getRenderer(): Vex.Flow.Renderer {
|
|
|
return this.renderer;
|
|
|
}
|
|
@@ -42,13 +54,7 @@ export abstract class VexFlowBackend {
|
|
|
|
|
|
// note: removing single children to remove all is error-prone, because sometimes a random SVG-child remains.
|
|
|
public removeFromContainer(container: HTMLElement): void {
|
|
|
- //console.log("backend type: " + this.getVexflowBackendType());
|
|
|
- let htmlElementToRemove: HTMLElement = this.canvas; // for SVGBackend
|
|
|
- if (this.getVexflowBackendType() === Vex.Flow.Renderer.Backends.CANVAS) {
|
|
|
- htmlElementToRemove = this.inner;
|
|
|
- // for SVG, this.canvas === this.inner, but for Canvas, removing this.canvas causes an error because it's not a child of container,
|
|
|
- // so we have to remove this.inner instead.
|
|
|
- }
|
|
|
+ const htmlElementToRemove: HTMLElement = this.getRenderElement();
|
|
|
|
|
|
// only remove child if the container has this child, otherwise it will throw an error.
|
|
|
for (let i: number = 0; i < container.children.length; i++) {
|