@@ -86,6 +86,7 @@ namespace FilterUtil {
8686 * @param {ParseOptions } data The parse options.
8787 */
8888 export let combineRelations = function ( arg : { data : ParseOptions } ) {
89+ const remove : MmlNode [ ] = [ ] ;
8990 for ( let mo of arg . data . getList ( 'mo' ) ) {
9091 if ( mo . getProperty ( 'relationsCombined' ) || ! mo . parent ||
9192 ( mo . parent && ! NodeUtil . isType ( mo . parent , 'mrow' ) ) ||
@@ -111,6 +112,7 @@ namespace FilterUtil {
111112 _copyExplicit ( [ 'stretchy' , 'rspace' ] , mo , m2 ) ;
112113 NodeUtil . setProperties ( mo , m2 . getAllProperties ( ) ) ;
113114 children . splice ( next , 1 ) ;
115+ remove . push ( m2 ) ;
114116 m2 . parent = null ;
115117 m2 . setProperty ( 'relationsCombined' , true ) ;
116118 } else {
@@ -127,7 +129,8 @@ namespace FilterUtil {
127129 }
128130 }
129131 mo . attributes . setInherited ( 'form' , ( mo as MmlMo ) . getForms ( ) [ 0 ] ) ;
130- }
132+ }
133+ arg . data . removeFromList ( 'mo' , remove ) ;
131134 } ;
132135
133136
@@ -191,6 +194,7 @@ namespace FilterUtil {
191194 * @param {string } up String representing the upper part.
192195 */
193196 let _cleanSubSup = function ( options : ParseOptions , low : string , up : string ) {
197+ const remove : MmlNode [ ] = [ ] ;
194198 for ( let mml of options . getList ( 'm' + low + up ) as any [ ] ) {
195199 const children = mml . childNodes ;
196200 if ( children [ mml [ low ] ] && children [ mml [ up ] ] ) {
@@ -206,7 +210,9 @@ namespace FilterUtil {
206210 } else {
207211 options . root = newNode ;
208212 }
213+ remove . push ( mml ) ;
209214 }
215+ options . removeFromList ( 'm' + low + up , remove ) ;
210216 } ;
211217
212218
@@ -235,8 +241,9 @@ namespace FilterUtil {
235241 * @param {ParseOptions } data The parse options.
236242 */
237243 let _moveLimits = function ( options : ParseOptions , underover : string , subsup : string ) {
244+ const remove : MmlNode [ ] = [ ] ;
238245 for ( const mml of options . getList ( underover ) ) {
239- if ( mml . attributes . get ( 'displaystyle' ) ) {
246+ if ( mml . attributes . get ( 'displaystyle' ) || mml . getProperty ( 'removed' ) ) {
240247 continue ;
241248 }
242249 const base = mml . childNodes [ ( mml as any ) . base ] as MmlNode ;
@@ -249,8 +256,10 @@ namespace FilterUtil {
249256 } else {
250257 options . root = node ;
251258 }
259+ remove . push ( mml ) ;
252260 }
253261 }
262+ options . removeFromList ( underover , remove ) ;
254263 } ;
255264
256265 /**
0 commit comments