From 4b5e2362fec2263cdf87e47debdfe8a6c3e5b395 Mon Sep 17 00:00:00 2001 From: Ed Sanders Date: Tue, 30 Jun 2020 16:14:17 +0100 Subject: [PATCH] VE: Add explicit dependency on targetLoader Change-Id: Ied1af70713b3595b87e2ea2f45797777f32ff7a0 --- .../ve.init.mw.AbuseFilterSaveErrorHandler.js | 40 ++++++++++--------- 1 file changed, 21 insertions(+), 19 deletions(-) diff --git a/modules/ve-abusefilter/ve.init.mw.AbuseFilterSaveErrorHandler.js b/modules/ve-abusefilter/ve.init.mw.AbuseFilterSaveErrorHandler.js index 68c8a1bc6..6c8d20c26 100644 --- a/modules/ve-abusefilter/ve.init.mw.AbuseFilterSaveErrorHandler.js +++ b/modules/ve-abusefilter/ve.init.mw.AbuseFilterSaveErrorHandler.js @@ -1,27 +1,29 @@ -mw.libs.ve.targetLoader.addPlugin( function () { +mw.loader.using( 'ext.visualEditor.targetLoader' ).then( function () { + mw.libs.ve.targetLoader.addPlugin( function () { - ve.init.mw.AbuseFilterSaveErrorHandler = function () {}; + ve.init.mw.AbuseFilterSaveErrorHandler = function () {}; - OO.inheritClass( ve.init.mw.AbuseFilterSaveErrorHandler, ve.init.mw.SaveErrorHandler ); + OO.inheritClass( ve.init.mw.AbuseFilterSaveErrorHandler, ve.init.mw.SaveErrorHandler ); - ve.init.mw.AbuseFilterSaveErrorHandler.static.name = 'abuseFilter'; + ve.init.mw.AbuseFilterSaveErrorHandler.static.name = 'abuseFilter'; - ve.init.mw.AbuseFilterSaveErrorHandler.static.matchFunction = function ( data ) { - return data.errors && data.errors.some( function ( err ) { - return err.code === 'abusefilter-disallowed' || err.code === 'abusefilter-warning'; - } ); - }; + ve.init.mw.AbuseFilterSaveErrorHandler.static.matchFunction = function ( data ) { + return data.errors && data.errors.some( function ( err ) { + return err.code === 'abusefilter-disallowed' || err.code === 'abusefilter-warning'; + } ); + }; - ve.init.mw.AbuseFilterSaveErrorHandler.static.process = function ( data, target ) { - var isWarning = data.errors.every( function ( err ) { - return err.code === 'abusefilter-warning'; - } ); - // Handle warnings/errors from Extension:AbuseFilter - target.showSaveError( target.extractErrorMessages( data ), isWarning, isWarning ); - // Emit event for tracking. TODO: This is a bad design - target.emit( 'saveErrorAbuseFilter' ); - }; + ve.init.mw.AbuseFilterSaveErrorHandler.static.process = function ( data, target ) { + var isWarning = data.errors.every( function ( err ) { + return err.code === 'abusefilter-warning'; + } ); + // Handle warnings/errors from Extension:AbuseFilter + target.showSaveError( target.extractErrorMessages( data ), isWarning, isWarning ); + // Emit event for tracking. TODO: This is a bad design + target.emit( 'saveErrorAbuseFilter' ); + }; - ve.init.mw.saveErrorHandlerFactory.register( ve.init.mw.AbuseFilterSaveErrorHandler ); + ve.init.mw.saveErrorHandlerFactory.register( ve.init.mw.AbuseFilterSaveErrorHandler ); + } ); } );