jenkins-bot has submitted this change and it was merged. Change subject: Relax section id validations in mw.cx.getSourceSection and getTranslationSection ......................................................................
Relax section id validations in mw.cx.getSourceSection and getTranslationSection These section ids are generated by parsoid. Usually it is prefixed with 'mw'. But it is not guaranteed. Sometimes templates assign their own ids to sections This commit removes the validations for prefixes because we need to accept ids from templates as well. Bug: T112253 Change-Id: I6875f6445d43039bc191d02295675b09315bf00c --- M modules/util/ext.cx.util.js 1 file changed, 17 insertions(+), 12 deletions(-) Approvals: Amire80: Looks good to me, approved jenkins-bot: Verified diff --git a/modules/util/ext.cx.util.js b/modules/util/ext.cx.util.js index d279bf8..6934026 100644 --- a/modules/util/ext.cx.util.js +++ b/modules/util/ext.cx.util.js @@ -37,22 +37,27 @@ return sectionTypes.join( ',' ); }; + /** + * Get the source section by a given Id. These Ids are generated + * by parsoid. Usually it is prefixed with 'mw'. But it is not + * guaranteed. Sometimes templates assign their own ids to sections. + * See T112253 + * + * @param {string} id Source section id. + * @return {jQuery} + */ mw.cx.getSourceSection = function ( id ) { - // Sanity check, id should be either a number or prefixed with mw - if ( !id || ( isNaN( id ) && id.indexOf( 'mw' ) !== 0 ) ) { - return $( [] ); - } else { - return $( document.getElementById( id ) ); - } + return $( document.getElementById( id ) ); }; + /** + * Get the target section by a given source section Id. + * + * @param {string} id Source section id. + * @return {jQuery} + */ mw.cx.getTranslationSection = function ( id ) { - // Sanity check - if ( !id || isNaN( id ) && id.indexOf( 'mw' ) !== 0 ) { - return $( [] ); - } else { - return $( document.getElementById( 'cx' + id ) ); - } + return $( document.getElementById( 'cx' + id ) ); }; /** -- To view, visit https://gerrit.wikimedia.org/r/241624 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: merged Gerrit-Change-Id: I6875f6445d43039bc191d02295675b09315bf00c Gerrit-PatchSet: 2 Gerrit-Project: mediawiki/extensions/ContentTranslation Gerrit-Branch: master Gerrit-Owner: Santhosh <santhosh.thottin...@gmail.com> Gerrit-Reviewer: Amire80 <amir.ahar...@mail.huji.ac.il> Gerrit-Reviewer: Nikerabbit <niklas.laxst...@gmail.com> Gerrit-Reviewer: jenkins-bot <> _______________________________________________ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits