Debian Codegraph @

resources/src/mediawiki.htmlform/autoinfuse.js

raw symbols SCIP
1 /*
2 * HTMLForm enhancements:
3 * Infuse some OOUI HTMLForm fields (those which benefit from always being infused).
4 */
5 mw.hook( 'htmlform.enhance' ).add( ( $root ) => {
6 let $oouiNodes = $root.find( '.mw-htmlform-autoinfuse' );
7
8 $oouiNodes = $oouiNodes.filter( function () {
9 return !$( this ).closest( '.mw-htmlform-autoinfuse-lazy' ).length;
10 } );
11
12 if ( $oouiNodes.length ) {
13 // The modules are preloaded (added server-side in HTMLFormField, and the individual fields
14 // which need extra ones), but this module doesn't depend on them. Wait until they're loaded.
15 const modules = [ 'mediawiki.htmlform.ooui' ];
16 $oouiNodes.each( function () {
17 const data = $( this ).data( 'mw-modules' );
18 if ( data ) {
19 // We can trust this value, 'data-mw-*' attributes are banned from user content in Sanitizer
20 const extraModules = data.split( ',' );
21 modules.push( ...extraModules );
22 }
23 } );
24 mw.loader.using( modules ).done( () => {
25 $oouiNodes.each( function () {
26 OO.ui.infuse( this );
27 } );
28 } );
29 }
30 } );