mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/Cite
synced 2024-09-23 10:20:12 +00:00
Merge "Helper function getAllGroupNames"
This commit is contained in:
commit
a9b8380bcb
|
@ -53,8 +53,7 @@ ve.dm.MWDocumentReferences.static.refsForDoc = function ( fragment ) {
|
|||
* @private
|
||||
*/
|
||||
ve.dm.MWDocumentReferences.prototype.updateAllGroups = function () {
|
||||
const nodes = this.doc.getInternalList().getNodeGroups();
|
||||
this.updateGroups( Object.keys( nodes ) );
|
||||
this.updateGroups( this.getAllGroupNames() );
|
||||
};
|
||||
|
||||
/**
|
||||
|
@ -91,6 +90,10 @@ ve.dm.MWDocumentReferences.prototype.updateGroup = function ( groupName ) {
|
|||
this.cachedByGroup[ groupName ] = indexNumberLookup;
|
||||
};
|
||||
|
||||
ve.dm.MWDocumentReferences.prototype.getAllGroupNames = function () {
|
||||
return Object.keys( this.doc.getInternalList().getNodeGroups() );
|
||||
};
|
||||
|
||||
/**
|
||||
* Return a formatted number, in the content script, with no separators.
|
||||
*
|
||||
|
|
|
@ -141,8 +141,7 @@ ve.ui.MWReferenceSearchWidget.prototype.buildIndex = function () {
|
|||
*/
|
||||
ve.ui.MWReferenceSearchWidget.prototype.buildSearchIndex = function () {
|
||||
const docRefs = ve.dm.MWDocumentReferences.static.refsForDoc( this.internalList.getDocument() );
|
||||
const groups = this.internalList.getNodeGroups();
|
||||
const groupNames = Object.keys( groups ).sort();
|
||||
const groupNames = docRefs.getAllGroupNames().sort();
|
||||
|
||||
// FIXME: Temporary hack, to be removed soon
|
||||
// eslint-disable-next-line no-jquery/no-class-state
|
||||
|
|
|
@ -3,11 +3,13 @@
|
|||
QUnit.module( 've.ui.MWReferenceSearchWidget (Cite)', ve.test.utils.newMwEnvironment() );
|
||||
|
||||
function getInternalListMock( groups, mockWithNode ) {
|
||||
groups = groups || {};
|
||||
const node = mockWithNode ? {
|
||||
getAttribute: () => ( 'literal/foo' ),
|
||||
getAttributes: () => ( {} )
|
||||
} : {};
|
||||
const refDocMock = {
|
||||
getAllGroupNames: () => ( Object.keys( groups ) ),
|
||||
getGroupRefsByParents: () => ( { '': [ node ] } ),
|
||||
getIndexNumber: () => ( 1 ),
|
||||
getItemNode: () => ( node )
|
||||
|
@ -18,7 +20,7 @@ function getInternalListMock( groups, mockWithNode ) {
|
|||
};
|
||||
const mockInternalList = {
|
||||
getDocument: () => ( docMock ),
|
||||
getNodeGroups: () => ( groups || {} ),
|
||||
getNodeGroups: () => ( groups ),
|
||||
getItemNode: () => ( node )
|
||||
};
|
||||
docMock.getInternalList = () => ( mockInternalList );
|
||||
|
|
Loading…
Reference in a new issue