Skip to content

Commit 268bce7

Browse files
committed
Merge branch 'maction-events' into alpha
2 parents f883d40 + 8b40a44 commit 268bce7

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

mathjax3-ts/handlers/html/HTMLMathItem.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ export class HTMLMathItem<N, T, D> extends AbstractMathItem<N, T, D> {
7575
if (this.inputJax.processStrings) {
7676
let node = this.start.node as T;
7777
if (node === this.end.node) {
78-
if (this.end.n < this.adaptor.value(this.end.node).length) {
78+
if (this.end.n && this.end.n < this.adaptor.value(this.end.node).length) {
7979
this.adaptor.split(this.end.node, this.end.n);
8080
}
8181
if (this.start.n) {

mathjax3-ts/output/chtml/Wrappers/maction.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,14 @@ export class CHTMLmaction<N, T, D> extends CHTMLWrapper<N, T, D> {
9797
// Add a click handler that changes the selection and rerenders the expression
9898
//
9999
node.setEventHandler('click', (event: Event) => {
100+
if (!math.start.node) {
101+
//
102+
// If the MathItem was created by hand, it might not have a node
103+
// telling it where to replace the existing math, so set it.
104+
//
105+
math.start.node = math.end.node = math.typesetRoot;
106+
math.start.n = math.end.n = 0;
107+
}
100108
mml.nextToggleSelection();
101109
math.rerender(document);
102110
event.stopPropagation();

0 commit comments

Comments
 (0)