For MediaWiki (recent comments | status changes | tags | authors | states | release notes | statistics)
I can't check it out right now, but shouldn't this be after :
var $collapsible = $that.eq(0).closest( '.mw-collapsible.mw-made-collapsible' ).toggleClass( 'mw-collapsed' );
Right now the return is making it return early.
I get that a link would take the user to a new address, so what would it matter ? Well not every Anchor tag is an external link. It could be linking to a section on the current page or something that is also bound by javascript, in which case the collapse/expand should still happen.