@@ -144,6 +144,7 @@ export interface MmlNode extends Node<MmlNode, MmlNodeClass> {
144144 readonly isSpacelike : boolean ;
145145 readonly linebreakContainer : boolean ;
146146 readonly linebreakAlign : string ;
147+ readonly isEmpty : boolean ;
147148
148149 /**
149150 * The expected number of children (-1 means use inferred mrow)
@@ -540,6 +541,16 @@ export abstract class AbstractMmlNode
540541 return 'data-align' ;
541542 }
542543
544+ /**
545+ * @returns {string } True if all child nodes are empty
546+ */
547+ public get isEmpty ( ) : boolean {
548+ for ( const child of this . childNodes ) {
549+ if ( ! child . isEmpty ) return false ;
550+ }
551+ return true ;
552+ }
553+
543554 /**
544555 * @returns {number } The number of children allowed, or Infinity for any number,
545556 * or -1 for when an inferred row is needed for the children.
@@ -1023,6 +1034,18 @@ export abstract class AbstractMmlTokenNode extends AbstractMmlNode {
10231034 return true ;
10241035 }
10251036
1037+ /**
1038+ * @override
1039+ */
1040+ public get isEmpty ( ) {
1041+ for ( const child of this . childNodes ) {
1042+ if ( ! ( child instanceof TextNode ) || child . getText ( ) . length ) {
1043+ return false ;
1044+ }
1045+ }
1046+ return true ;
1047+ }
1048+
10261049 /**
10271050 * Get the text of the token node (skipping mglyphs, and combining
10281051 * multiple text nodes)
@@ -1228,6 +1251,13 @@ export abstract class AbstractMmlEmptyNode
12281251 return false ;
12291252 }
12301253
1254+ /**
1255+ * @returns {boolean } Is empty
1256+ */
1257+ public get isEmpty ( ) : boolean {
1258+ return true ;
1259+ }
1260+
12311261 /**
12321262 * @returns {boolean } Not embellished
12331263 */
0 commit comments