From a531d4d82ddda2788621bfe1c62faf5a1df775ea Mon Sep 17 00:00:00 2001 From: thiemowmde Date: Thu, 2 May 2024 17:09:16 +0200 Subject: [PATCH] Streamline code dealing with (undeployed) extends attribute No need to create an expensive model here when all we need is a single attribute. Note this code is still behind a feature flag and not running anywhere, except on the beta cluster. Bug: T247922 Change-Id: Iea48837213b72a8d0f4b3cc9d9688d9a08315509 --- modules/ve-cite/ve.ui.MWReferenceContextItem.js | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/modules/ve-cite/ve.ui.MWReferenceContextItem.js b/modules/ve-cite/ve.ui.MWReferenceContextItem.js index 3f0a9eab2..c0afb09a5 100644 --- a/modules/ve-cite/ve.ui.MWReferenceContextItem.js +++ b/modules/ve-cite/ve.ui.MWReferenceContextItem.js @@ -93,9 +93,7 @@ ve.ui.MWReferenceContextItem.prototype.getReuseWarning = function () { * @return {jQuery|null} */ ve.ui.MWReferenceContextItem.prototype.getExtendsWarning = function () { - const refModel = ve.dm.MWReferenceModel.static.newFromReferenceNode( this.model ); - - if ( refModel.extendsRef ) { + if ( this.model.getAttribute( 'extendsRef' ) ) { return $( '
' ) .addClass( 've-ui-mwReferenceContextItem-muted' ) .text( mw.msg( 'cite-ve-dialog-reference-editing-extends' ) ); @@ -133,12 +131,12 @@ ve.ui.MWReferenceContextItem.prototype.getDescription = function () { * @return {string|null} */ ve.ui.MWReferenceContextItem.prototype.getParentRef = function () { - const refModel = ve.dm.MWReferenceModel.static.newFromReferenceNode( this.model ); - if ( !refModel.extendsRef ) { + const extendsRef = this.model.getAttribute( 'extendsRef' ); + if ( !extendsRef ) { return null; } const list = this.getFragment().getDocument().getInternalList(); - const index = list.keys.indexOf( 'literal/' + refModel.extendsRef ); + const index = list.keys.indexOf( 'literal/' + extendsRef ); return list.getItemNode( index ).element.attributes.originalHtml; };