From a1c003d77a973ade976a6370733922344c32eb27 Mon Sep 17 00:00:00 2001 From: Brian Carlsen Date: Mon, 1 Nov 2021 10:10:28 +0100 Subject: [PATCH] Fixed bug when iterating over mutations. --- src/md_processor.ts | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/md_processor.ts b/src/md_processor.ts index fbd0545..22c0364 100644 --- a/src/md_processor.ts +++ b/src/md_processor.ts @@ -11,25 +11,26 @@ export function captionObserver( plugin: Plugin ) { return new MutationObserver( ( mutations, observer ) => { for ( const mutation of mutations ) { if ( !mutation.target.matches( 'span.image-embed' ) ) { - return; + continue; } const caption_text = mutation.target.getAttribute( 'alt' ); if ( caption_text === mutation.target.getAttribute( 'src' ) ) { // default caption, skip - return; + continue; } if ( mutation.target.querySelector( plugin.caption_selector ) ) { // caption already added - return; + continue; } addCaption( mutation.target, caption_text, plugin ); - updateFigureIndices( plugin ); } // end for..of + updateFigureIndices( plugin ); plugin.removeObserver( observer ); + } ); }