Fix href parsing in transclusion nodes when on alternative (e.g. mobile) domains/paths

Use model HTMLDocument when parsing transclusion nodes and their link hrefs

As well as mobile, this also covers the issue I found in /w/index.php?veaction=edit

See also T76374

Bug: T76379
Change-Id: I07c9ba0adbcee32f7eb2ca280d3a1d46e963d28f
This commit is contained in:
Alex Monk 2014-12-05 20:19:15 +00:00
parent b0b53befdc
commit a7b9b89479

View file

@ -102,7 +102,7 @@ ve.ce.MWTransclusionNode.prototype.onParseSuccess = function ( deferred, respons
return this.onParseError.call( this, deferred );
}
contentNodes = $.parseHTML( response.visualeditor.content );
contentNodes = $.parseHTML( response.visualeditor.content, this.getModelHtmlDocument() );
// HACK: if $content consists of a single paragraph, unwrap it.
// We have to do this because the PHP parser wraps everything in <p>s, and inline templates
// will render strangely when wrapped in <p>s.
@ -129,12 +129,13 @@ ve.ce.MWTransclusionNode.prototype.onParseSuccess = function ( deferred, respons
* @inheritdoc
*/
ve.ce.MWTransclusionNode.prototype.getRenderedDomElements = function ( domElements ) {
var $elements = this.$( ve.ce.GeneratedContentNode.prototype.getRenderedDomElements.call( this, domElements ) );
var $elements = this.$( ve.ce.GeneratedContentNode.prototype.getRenderedDomElements.call( this, domElements ) ),
transclusionNode = this;
$elements
.find( 'a[href][rel="mw:WikiLink"]' ).addBack( 'a[href][rel="mw:WikiLink"]' )
.each( function () {
var targetData = ve.dm.MWInternalLinkAnnotation.static.getTargetDataFromHref(
this.href, this.ownerDocument
this.href, transclusionNode.getModelHtmlDocument()
),
normalisedHref = decodeURIComponent( targetData.title );
if ( mw.Title.newFromText( normalisedHref ) ) {