After this patch, we have:
let sourceImage, textChunks; textChunks = this.isInlineImage ? [] : this.node.children.textChunks; for ( let i = 0, len = textChunks.length; i < len; i++ ) { // <some logic to set sourceImage variable> } if ( this.isInlineImage && this.node.attributes[ 'data-mw' ] ) { // <parts of code where sourceImage isn't assigned to> return this.node; } if ( !sourceImage ) { throw new Error( 'img tag not found in the figure with mw:Image/Thumb for id: ' + this.node.attributes.id ); }
From the above, if this.isInlineImage is true, textChunks will be empty array, thus for loop won't do anything. sourceImage remains undefined in that scenario.
If condition if ( this.isInlineImage && this.node.attributes[ 'data-mw' ] ) does not pass, like in case of inline images with no caption, we will definitely have an error thrown.
This was found while trying to reproduce T199308. There is one example how to reproduce this ("Uma Thurman" from English to Spanish).