From 76aa5d9cb40530b0a2117eed89822271c35d4bf5 Mon Sep 17 00:00:00 2001 From: WMDE-Fisch Date: Thu, 31 Oct 2024 15:13:22 +0100 Subject: [PATCH] Also count sub-ref re-uses when getting total usages Bug: T373023 Change-Id: I12a37be8a1e26d25b152eb929f41188675e35038 --- modules/ve-cite/ve.dm.MWGroupReferences.js | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/modules/ve-cite/ve.dm.MWGroupReferences.js b/modules/ve-cite/ve.dm.MWGroupReferences.js index 6fb05bae0..7f5699359 100644 --- a/modules/ve-cite/ve.dm.MWGroupReferences.js +++ b/modules/ve-cite/ve.dm.MWGroupReferences.js @@ -217,7 +217,11 @@ ve.dm.MWGroupReferences.prototype.getTotalUsageCount = function ( listKey ) { const mainRefsCount = mainRefs.length; const subrefs = this.getSubrefs( listKey ); - const subrefsCount = subrefs.length; + + let subrefsCount = 0; + subrefs.forEach( ( node ) => { + subrefsCount += this.getRefUsages( node.getAttribute( 'listKey' ) ).length; + } ); const totalUsageCount = mainRefsCount + subrefsCount; @@ -226,7 +230,7 @@ ve.dm.MWGroupReferences.prototype.getTotalUsageCount = function ( listKey ) { /** * @param {string} parentKey parent ref key - * @return {ve.dm.MWReferenceNode[]} List of subrefs for this parent + * @return {ve.dm.MWReferenceNode[]} List of subrefs for this parent not including re-uses */ ve.dm.MWGroupReferences.prototype.getSubrefs = function ( parentKey ) { return this.subRefsByParent[ parentKey ] || [];