mw.htmlform: Don't refer to OO.ui if it might not be loaded
authorBartosz Dziewoński <matma.rex@gmail.com>
Thu, 25 Aug 2016 04:34:35 +0000 (06:34 +0200)
committerBartosz Dziewoński <matma.rex@gmail.com>
Thu, 25 Aug 2016 04:34:35 +0000 (06:34 +0200)
Dependencies are loaded dynamically here, before this code runs.
If there are no OOjs UI HTMLForm fields on the page, then OOjs UI
is not loaded, and the attempt to check if we're working with a
OO.ui.Widget would cause an exception. Invert the test to check
for jQuery, which is always loaded.

Follow-up to 89107070d14187915e760f8543579ec4d784620f.

Bug: T143850
Change-Id: Ibaa5a15fe367ed7470e3e8176e52b13442aeb985

resources/src/mediawiki/htmlform/hide-if.js

index cb717af..0fbbcbe 100644 (file)
                                }
                                v = spec[ 2 ];
 
-                               if ( field instanceof OO.ui.Widget ) {
+                               if ( !( field instanceof jQuery ) ) {
+                                       // field is a OO.ui.Widget
                                        if ( field.supports( 'isSelected' ) ) {
                                                getVal = function () {
                                                        var selected = field.isSelected();