Skip to content

Commit

Permalink
Prevent handler from trying to remove typeset math that is no longer …
Browse files Browse the repository at this point in the history
…in teh document
  • Loading branch information
dpvc committed Sep 22, 2019
1 parent 2972b78 commit d687ac7
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions ts/handlers/html/HTMLMathItem.ts
Original file line number Diff line number Diff line change
Expand Up @@ -119,18 +119,21 @@ export class HTMLMathItem<N, T, D> extends AbstractMathItem<N, T, D> {
*/
public removeFromDocument(restore: boolean = false) {
if (this.state() >= STATE.TYPESET) {
const adaptor = this.adaptor;
let node = this.start.node;
let math: N | T = this.adaptor.text('');
let math: N | T = adaptor.text('');
if (restore) {
let text = this.start.delim + this.math + this.end.delim;
if (this.inputJax.processStrings) {
math = this.adaptor.text(text);
math = adaptor.text(text);
} else {
const doc = this.adaptor.parse(text, 'text/html');
math = this.adaptor.firstChild(this.adaptor.body(doc));
const doc = adaptor.parse(text, 'text/html');
math = adaptor.firstChild(adaptor.body(doc));
}
}
this.adaptor.replace(math, node);
if (adaptor.parent(node)) {
adaptor.replace(math, node);
}
this.start.node = this.end.node = math;
this.start.n = this.end.n = 0;
}
Expand Down

0 comments on commit d687ac7

Please sign in to comment.