diff --git a/modules/ve-cite/ve.ce.MWReferencesListNode.js b/modules/ve-cite/ve.ce.MWReferencesListNode.js index 15311acc9..aa67c5dc0 100644 --- a/modules/ve-cite/ve.ce.MWReferencesListNode.js +++ b/modules/ve-cite/ve.ce.MWReferencesListNode.js @@ -275,7 +275,7 @@ ve.ce.MWReferencesListNode.prototype.renderListItem = function ( nodes, internal ); const $li = $( '
  • ' ) - .css( '--footnote-number', `"${ this.docRefs.getIndexNumber( refGroup, key ) }."` ) + .css( '--footnote-number', `"${ this.docRefs.getIndexLabel( refGroup, key ) }."` ) .append( this.renderBacklinks( keyedNodes, refGroup ), ' ' ); // Generate reference HTML from first item in key diff --git a/modules/ve-cite/ve.dm.MWDocumentReferences.js b/modules/ve-cite/ve.dm.MWDocumentReferences.js index 05d700ea8..b5cd4de83 100644 --- a/modules/ve-cite/ve.dm.MWDocumentReferences.js +++ b/modules/ve-cite/ve.dm.MWDocumentReferences.js @@ -114,14 +114,14 @@ ve.dm.MWDocumentReferences.static.contentLangDigits = function ( num ) { }; /** - * @deprecated Should be refactored to store index numbers as a simple property - * in each ref node after document transaction. + * @deprecated Should be refactored to store formatted index numbers as a simple + * property on each CE ref node after document transaction. * @param {string} groupName Ref group without prefix * @param {string} listKey Ref key with prefix * @return {string} Rendered index number string which can be used as a footnote * marker or reflist item number. */ -ve.dm.MWDocumentReferences.prototype.getIndexNumber = function ( groupName, listKey ) { +ve.dm.MWDocumentReferences.prototype.getIndexLabel = function ( groupName, listKey ) { return ( this.cachedByGroup[ 'mwReference/' + groupName ] || {} )[ listKey ]; }; diff --git a/modules/ve-cite/ve.dm.MWReferenceNode.js b/modules/ve-cite/ve.dm.MWReferenceNode.js index 530d1c734..7bc9fcc38 100644 --- a/modules/ve-cite/ve.dm.MWReferenceNode.js +++ b/modules/ve-cite/ve.dm.MWReferenceNode.js @@ -339,7 +339,7 @@ ve.dm.MWReferenceNode.static.getIndexLabel = function ( dataElement, internalLis ve.dm.MWReferenceNode.static.findIndexNumber = function ( dataElement, internalList ) { return ve.getProp( dataElement, 'internal', 'overrideIndex' ) || ve.dm.MWDocumentReferences.static.refsForDoc( internalList.getDocument() ) - .getIndexNumber( dataElement.attributes.refGroup, dataElement.attributes.listKey ); + .getIndexLabel( dataElement.attributes.refGroup, dataElement.attributes.listKey ); }; /** diff --git a/modules/ve-cite/ve.ui.MWReferenceSearchWidget.js b/modules/ve-cite/ve.ui.MWReferenceSearchWidget.js index 9f78c9451..4b4fbc363 100644 --- a/modules/ve-cite/ve.ui.MWReferenceSearchWidget.js +++ b/modules/ve-cite/ve.ui.MWReferenceSearchWidget.js @@ -170,7 +170,7 @@ ve.ui.MWReferenceSearchWidget.prototype.buildSearchIndex = function () { const listKey = node.getAttribute( 'listKey' ); // remove `mwReference/` prefix const group = groupName.slice( 12 ); - const footnoteNumber = docRefs.getIndexNumber( group, listKey ); + const footnoteNumber = docRefs.getIndexLabel( group, listKey ); const citation = ( group ? group + ' ' : '' ) + footnoteNumber; // Use [\s\S]* instead of .* to catch esoteric whitespace (T263698) diff --git a/tests/qunit/ve-cite/ve.dm.MWDocumentReferences.test.js b/tests/qunit/ve-cite/ve.dm.MWDocumentReferences.test.js index 20bc58782..ea4f5fd2d 100644 --- a/tests/qunit/ve-cite/ve.dm.MWDocumentReferences.test.js +++ b/tests/qunit/ve-cite/ve.dm.MWDocumentReferences.test.js @@ -17,8 +17,8 @@ QUnit.test( 'first simple test', ( assert ) => { assert.strictEqual( firstListKey, 'auto/0' ); assert.strictEqual( fooGroupListKey, 'auto/2' ); - assert.strictEqual( docRefs.getIndexNumber( '', firstListKey ), '1' ); - assert.strictEqual( docRefs.getIndexNumber( 'foo', fooGroupListKey ), '1' ); + assert.strictEqual( docRefs.getIndexLabel( '', firstListKey ), '1' ); + assert.strictEqual( docRefs.getIndexLabel( 'foo', fooGroupListKey ), '1' ); } ); QUnit.test( 'extends test', ( assert ) => { @@ -35,10 +35,10 @@ QUnit.test( 'extends test', ( assert ) => { const firstListKey = groupedRefs[ '' ][ 0 ].getAttribute( 'listKey' ); assert.strictEqual( firstListKey, 'auto/1' ); // FIXME: Documents incorrect behavior, should be '2'. - assert.strictEqual( docRefs.getIndexNumber( '', firstListKey ), '1' ); + assert.strictEqual( docRefs.getIndexLabel( '', firstListKey ), '1' ); const subrefListKey = groupedRefs[ 'literal/ldr' ][ 0 ].getAttribute( 'listKey' ); assert.strictEqual( subrefListKey, 'auto/0' ); // FIXME: Documents incorrect behavior, should be '1.1'. - assert.strictEqual( docRefs.getIndexNumber( '', subrefListKey ), '2.1' ); + assert.strictEqual( docRefs.getIndexLabel( '', subrefListKey ), '2.1' ); } ); diff --git a/tests/qunit/ve-cite/ve.ui.MWReferenceSearchWidget.test.js b/tests/qunit/ve-cite/ve.ui.MWReferenceSearchWidget.test.js index ad0877192..30eaadfdc 100644 --- a/tests/qunit/ve-cite/ve.ui.MWReferenceSearchWidget.test.js +++ b/tests/qunit/ve-cite/ve.ui.MWReferenceSearchWidget.test.js @@ -11,7 +11,7 @@ function getInternalListMock( groups, mockWithNode ) { const refDocMock = { getAllGroupNames: () => ( Object.keys( groups ) ), getGroupRefsByParents: () => ( { '': [ node ] } ), - getIndexNumber: () => ( 1 ), + getIndexLabel: () => ( '1' ), getItemNode: () => ( node ) }; const docMock = {