jenkins-bot has submitted this change and it was merged.
Change subject: Hack around Parsoid's href prefixing in rendering new links
......................................................................
Hack around Parsoid's href prefixing in rendering new links
If we render new links with a plain target, then if you're on a
subpage like Foo/Bar, [[Baz]] will point to Foo/Baz. In order to
avoid this, we fake the link target to be ../Baz and resolve that,
which produces the correct result.
This hack is only needed until Parsoid stops producing ../-prefixed
links. This hack is only applied in view mode, because applying
it to our DOM output back to Parsoid would confuse Parsoid and
cause bugs.
Bug: 58314
Change-Id: Ifb4b63a26235a04e6362fc3e3e57d8773831eb38
---
M modules/ve-mw/ce/annotations/ve.ce.MWInternalLinkAnnotation.js
1 file changed, 15 insertions(+), 0 deletions(-)
Approvals:
Krinkle: Looks good to me, approved
Catrope: Looks good to me, but someone else must approve
Jforrester: Looks good to me, approved
jenkins-bot: Verified
diff --git a/modules/ve-mw/ce/annotations/ve.ce.MWInternalLinkAnnotation.js
b/modules/ve-mw/ce/annotations/ve.ce.MWInternalLinkAnnotation.js
index a7974b0..cc88170 100644
--- a/modules/ve-mw/ce/annotations/ve.ce.MWInternalLinkAnnotation.js
+++ b/modules/ve-mw/ce/annotations/ve.ce.MWInternalLinkAnnotation.js
@@ -5,6 +5,8 @@
* @license The MIT License (MIT); see LICENSE.txt
*/
+/*global mw */
+
/**
* ContentEditable MediaWiki internal link annotation.
*
@@ -31,6 +33,19 @@
annotation.$element.addClass( 'new' );
}
} );
+
+ // HACK: Override href in case hrefPrefix isn't set
+ // This is a workaround for bug 58314 until such time as Parsoid gets
rid of
+ // ../-prefixed hrefs.
+ if ( this.model.getAttribute( 'hrefPrefix' ) === undefined ) {
+ this.$element.attr( 'href', ve.resolveUrl(
+ // Repeat '../' wgPageName.split( '/' ).length - 1 times
+ // (= the number of slashes in wgPageName)
+ new Array( mw.config.get( 'wgPageName' ).split( '/'
).length ).join( '../' ) +
+ this.model.getHref(),
+ this.getModelHtmlDocument()
+ ) );
+ }
};
/* Inheritance */
--
To view, visit https://gerrit.wikimedia.org/r/119914
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: Ifb4b63a26235a04e6362fc3e3e57d8773831eb38
Gerrit-PatchSet: 3
Gerrit-Project: mediawiki/extensions/VisualEditor
Gerrit-Branch: master
Gerrit-Owner: Catrope <[email protected]>
Gerrit-Reviewer: Catrope <[email protected]>
Gerrit-Reviewer: Esanders <[email protected]>
Gerrit-Reviewer: GWicke <[email protected]>
Gerrit-Reviewer: Jforrester <[email protected]>
Gerrit-Reviewer: Krinkle <[email protected]>
Gerrit-Reviewer: Subramanya Sastry <[email protected]>
Gerrit-Reviewer: jenkins-bot <>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits