2 * HTMLForm enhancements:
3 * Infuse some OOjs UI HTMLForm fields (those which benefit from always being infused).
7 mw.hook( 'htmlform.enhance' ).add( function ( $root ) {
8 var $oouiNodes, modules, extraModules;
10 $oouiNodes = $root.find( '.mw-htmlform-field-autoinfuse' );
11 if ( $oouiNodes.length ) {
12 // The modules are preloaded (added server-side in HTMLFormField, and the individual fields
13 // which need extra ones), but this module doesn't depend on them. Wait until they're loaded.
14 modules = [ 'mediawiki.htmlform.ooui' ];
15 $oouiNodes.each( function () {
16 var data = $( this ).data( 'mw-modules' );
18 // We can trust this value, 'data-mw-*' attributes are banned from user content in Sanitizer
19 extraModules = data.split( ',' );
20 modules.push.apply( modules, extraModules );
23 mw.loader.using( modules ).done( function () {
24 $oouiNodes.each( function () {
32 }( mediaWiki, jQuery ) );