2 * HTMLForm enhancements:
3 * Infuse some OOUI 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' );
12 $oouiNodes
= $oouiNodes
.filter( function () {
13 return !$( this ).closest( '.mw-htmlform-autoinfuse-lazy' ).length
;
16 if ( $oouiNodes
.length
) {
17 // The modules are preloaded (added server-side in HTMLFormField, and the individual fields
18 // which need extra ones), but this module doesn't depend on them. Wait until they're loaded.
19 modules
= [ 'mediawiki.htmlform.ooui' ];
20 $oouiNodes
.each( function () {
21 var data
= $( this ).data( 'mw-modules' );
23 // We can trust this value, 'data-mw-*' attributes are banned from user content in Sanitizer
24 extraModules
= data
.split( ',' );
25 modules
.push
.apply( modules
, extraModules
);
28 mw
.loader
.using( modules
).done( function () {
29 $oouiNodes
.each( function () {