Page MenuHomePhabricator

VisualEditor overwrites "edit source" link with JavaScript even when unnecessary, breaking the link in some skins
Closed, ResolvedPublicBUG REPORT

Description

VisualEditor runs the VisualEditorHooks::onSkinTemplateNavigation() hook to configure the "edit" and "edit source" links. In case the hook does not run, VE also uses JS to set up those links. The issue involves the JS if/else block starting here:

https://github.com/wikimedia/mediawiki-extensions-VisualEditor/blob/f2cc6d9fc00c8246950ebf753a3001800c29bae0/modules/ve-mw/preinit/ve.init.mw.DesktopArticleTarget.init.js#L713

This block overwrites the contents of the "edit source" link even if the hook already configured the link correctly. This causes formatting issues in third-party skins. For example, in the Refreshed skin, page tool links contain a span and an inline svg. When VE's JS overwrites the "edit source" link, it removes the link's span and svg elements, breaking the link's formatting.

The fix should be simple. Just move that if/else block from earlier into the if statement that starts here:

https://github.com/wikimedia/mediawiki-extensions-VisualEditor/blob/f2cc6d9fc00c8246950ebf753a3001800c29bae0/modules/ve-mw/preinit/ve.init.mw.DesktopArticleTarget.init.js#L651

That way, the JS will only overwrite the "edit source" link text if the hook didn't run.

Event Timeline

I don't think we can work on this, but I'd be happy to review a patch if you submit one.

Change 584037 had a related patch set uploaded (by MtMNC; owner: MtMNC):
[mediawiki/extensions/VisualEditor@master] Overwrite "edit source" link only when needed

https://gerrit.wikimedia.org/r/584037

@matmarex Thank you! I just submitted a patch for review.

Change 584037 merged by jenkins-bot:
[mediawiki/extensions/VisualEditor@master] Overwrite "edit source" link only when needed

https://gerrit.wikimedia.org/r/584037

matmarex assigned this task to MtMNC.
matmarex removed a project: Patch-For-Review.

Thanks!

Mentioned in SAL (#wikimedia-cloud) [2021-06-01T09:56:29Z] <arturo> fix PTR record for 185.15.56.1 (T248025)

Mentioned in SAL (#wikimedia-cloud) [2021-06-01T09:56:29Z] <arturo> fix PTR record for 185.15.56.1 (T248025)

(It looks like that comment was intended for T284025)