Don't bail out early when there are no selectors configured

It seems to me, that at this point 3rd parties might not have been
loaded that want to add custom preview types. So the list of
selectors is empty.

We still might want to initialze though for 3rd parties that load
later.

Bug: T355933
Change-Id: I5f293a134521f086c9f62babb9d06cd9c51d7d47
This commit is contained in:
WMDE-Fisch 2024-01-26 12:33:53 +01:00
parent 694b96a19f
commit bf10902f23
5 changed files with 2 additions and 33 deletions

Binary file not shown.

Binary file not shown.

View file

@ -22,8 +22,7 @@ import * as actions from './actions';
import reducers from './reducers';
import createMediaWikiPopupsObject from './integrations/mwpopups';
import { previewTypes, getPreviewType,
registerModel,
isAnythingEligible, findNearestEligibleTarget } from './preview/model';
registerModel, findNearestEligibleTarget } from './preview/model';
import setUserConfigFlags from './setUserConfigFlags';
import { registerGatewayForPreviewType, getGatewayForPreviewType } from './gateway';
import { FETCH_START_DELAY, FETCH_COMPLETE_TARGET_DELAY } from './constants';
@ -253,11 +252,6 @@ function handleDOMEventIfEligible( handler ) {
} );
}
if ( !isAnythingEligible() ) {
mw.log.warn( 'ext.popups was loaded but everything is disabled' );
return;
}
rendererInit();
/*

View file

@ -249,15 +249,6 @@ export function registerModel( type, selector, delay ) {
}
}
/**
* Check whether any kind of preview is enabled.
*
* @return {boolean}
*/
export function isAnythingEligible() {
return !!selectors.length;
}
export const test = {
/** For testing only */
reset: () => {

View file

@ -1,6 +1,6 @@
import {
createModel, getPreviewType, previewTypes, registerModel, test,
isAnythingEligible, findNearestEligibleTarget, createNullModel
findNearestEligibleTarget, createNullModel
} from '../../../src/preview/model';
QUnit.module( 'ext.popups.preview#createModel' );
@ -109,22 +109,6 @@ QUnit.module( 'ext.popups.preview#getPreviewType', {
}
} );
QUnit.test( 'isAnythingEligible returns false by default', function ( assert ) {
test.reset();
assert.strictEqual(
isAnythingEligible(),
false
);
} );
QUnit.test( 'isAnythingEligible returns true when model is registered', function ( assert ) {
this.registerRefModel();
assert.strictEqual(
isAnythingEligible(),
true
);
} );
QUnit.test( 'it uses the reference gateway with valid element', function ( assert ) {
this.registerRefModel();
assert.strictEqual(