import { CaretNode, h, VNode } from "@caret-js/core"; import { MathExpressionTag } from "../tags/mathExpression"; import { SubscriptNode } from "./subscript"; export class ExponentNode extends CaretNode { constructor(public base: CaretNode, public power: CaretNode) { super(); this.addTag(new MathExpressionTag()); } static from(base: CaretNode, power: CaretNode): ExponentNode { return new ExponentNode(base, power); } toDebugMathML(): VNode { if (this.base instanceof SubscriptNode) { return h( "msubsup", {}, this.base.child.toDebugMathML(), this.base.subscript.toDebugMathML(), this.power.toDebugMathML() ); } return h("msup", {}, this.base.toDebugMathML(), this.power.toDebugMathML()); } }