Avoid HTML string parsing

Identified using https://github.com/wikimedia/eslint-plugin-jquery/pull/12

Change-Id: I138e018fdc037d688e055eacddfdc5bfc2cc5abe
This commit is contained in:
Ed Sanders 2018-11-21 18:47:19 +00:00
parent 1a3e8a958c
commit f2a9ccd5bd
3 changed files with 5 additions and 5 deletions

View file

@ -77,7 +77,7 @@ ve.ce.MWExtensionNode.prototype.generateContents = function ( config ) {
.fail( this.onParseError.bind( this, deferred ) );
return deferred.promise( { abort: xhr.abort } );
} else {
deferred.resolve( $( '<span>&nbsp;</span>' ).get() );
deferred.resolve( $( '<span>' ).text( '\u00a0' ).get() );
return deferred.promise();
}
};

View file

@ -2644,7 +2644,7 @@ ve.init.mw.ArticleTarget.prototype.renderCategories = function ( categoryItems )
} ) );
} );
return $.when.apply( $, promises ).then( function () {
var $output = $( '<div class="catlinks" />' );
var $output = $( '<div>' ).addClass( 'catlinks' );
function renderPageLink( page ) {
var title = mw.Title.newFromText( page.category || page );
return $( '<a>' ).attr( 'rel', 'mw:WikiLink' ).attr( 'href', title.getUrl() ).text( title.getMainText() );
@ -2661,7 +2661,7 @@ ve.init.mw.ArticleTarget.prototype.renderCategories = function ( categoryItems )
}
if ( categories.normal.length ) {
categories.normal.sort( categorySort );
$normal = $( '<div class="mw-normal-catlinks" />' );
$normal = $( '<div>' ).addClass( 'mw-normal-catlinks' );
$normal.append(
renderPageLink( ve.msg( 'pagecategorieslink' ) ).text( ve.msg( 'pagecategories', categories.normal.length ) ),
ve.msg( 'colon-separator' ),
@ -2671,7 +2671,7 @@ ve.init.mw.ArticleTarget.prototype.renderCategories = function ( categoryItems )
}
if ( categories.hidden.length ) {
categories.hidden.sort( categorySort );
$hidden = $( '<div class="mw-hidden-catlinks" />' );
$hidden = $( '<div>' ).addClass( 'mw-hidden-catlinks' );
if ( mw.user.options.get( 'showhiddencats' ) ) {
$hidden.addClass( 'mw-hidden-cats-user-shown' );
} else if ( mw.config.get( 'wgNamespaceIds' ).category === mw.config.get( 'wgNamespaceNumber' ) ) {

View file

@ -63,7 +63,7 @@ ve.ui.MWLanguageVariantNodeContextItem.prototype.setup = function () {
ve.ui.MWLanguageVariantNodeContextItem.prototype.renderBody = function () {
var $body = this.$body,
$table = $( '<table>' ),
$header = $( '<tr> ' ),
$header = $( '<tr>' ),
variantInfo = this.model.getVariantInfo(),
type = this.model.getRuleType(),
isHidden = this.model.isHidden(),