Page MenuHomePhabricator

Conflict between VisualEditor and Attachments extensions
Open, Needs TriagePublic

Description

I just got a bug report for my Attachments extension, apparently if it's used along with the VisualEditor extension and a page is saved with the visual editor the page content get temporarily duplicated till the page is refreshed.

My Attachments extension displays the attachments of a page below the page content, and to get external links within the attachments section to be styled like in the page content I am wrapping the attachments section in a <div class="mw-parser-output"> so that e.g. the Vector skin applies its .mw-parser-output .external CSS rule.

Line 1382 of ve.init.mw.DesktopArticleTarget.js however does the following:

this.$editableContent.find( '.mw-parser-output' ).replaceWith( $content );

which unfortunately also finds the div added by my extension, leading to the initially linked bug.

So I am wondering if it would be possible to change the above mentioned line to:

this.$editableContent.find( '.mw-parser-output' ).first().replaceWith( $content );

which according to my jQuery knowledge should do the trick and skip the second .mw-parser-output div added by my extension.