Catrope has uploaded a new change for review.
https://gerrit.wikimedia.org/r/119914
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: 59196
Change-Id: Ifb4b63a26235a04e6362fc3e3e57d8773831eb38
---
M modules/ve-mw/ce/annotations/ve.ce.MWInternalLinkAnnotation.js
1 file changed, 15 insertions(+), 0 deletions(-)
git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/VisualEditor
refs/changes/14/119914/1
diff --git a/modules/ve-mw/ce/annotations/ve.ce.MWInternalLinkAnnotation.js
b/modules/ve-mw/ce/annotations/ve.ce.MWInternalLinkAnnotation.js
index a7974b0..9d5e5c6 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 59196 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: newchange
Gerrit-Change-Id: Ifb4b63a26235a04e6362fc3e3e57d8773831eb38
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/VisualEditor
Gerrit-Branch: master
Gerrit-Owner: Catrope <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits