mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/Popups
synced 2024-11-23 23:24:39 +00:00
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:
parent
694b96a19f
commit
bf10902f23
BIN
resources/dist/index.js
vendored
BIN
resources/dist/index.js
vendored
Binary file not shown.
BIN
resources/dist/index.js.map.json
vendored
BIN
resources/dist/index.js.map.json
vendored
Binary file not shown.
|
@ -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();
|
||||
|
||||
/*
|
||||
|
|
|
@ -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: () => {
|
||||
|
|
|
@ -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(
|
||||
|
|
Loading…
Reference in a new issue