mediawiki.htmlform: Fix broken $() call
authorBrad Jorsch <bjorsch@wikimedia.org>
Tue, 8 Jul 2014 19:15:49 +0000 (15:15 -0400)
committerTimo Tijhof <krinklemail@gmail.com>
Fri, 18 Jul 2014 02:23:27 +0000 (04:23 +0200)
Follows-up c310e7b40cdaa92bb06e.

The $( Array ) signature requires the list to contain DOM nodes,
not jQuery objects. The fields variable should be a list of
nodes, not jQuery collections.

Also:
* Improve @return documentation for hideIfParse().
* Flag hideIfParse() and hideIfGetField() as private to remove them
  from the jQuery#htmlform API documentation as methods that would
  be mixed into the jQuery prototype (they're not).

Bug: 67685
Change-Id: I4bb93ad234cdd4a1f412b759065138e2831be2a6

resources/src/mediawiki/mediawiki.htmlform.js

index 8be1321..9eea492 100644 (file)
@@ -15,6 +15,7 @@
         * ending in array keys matching the given name (e.g. "baz" matches
         * "foo[bar][baz]").
         *
+        * @private
         * @param {jQuery} element
         * @param {string} name
         * @return {jQuery|null}
         * Helper function for hide-if to return a test function and list of
         * dependent fields for a hide-if specification.
         *
+        * @private
         * @param {jQuery} element
         * @param {Array} hide-if spec
-        * @return {Array} 2 elements: jQuery of dependent fields, and test function
+        * @return {Array}
+        * @return {jQuery} return.0 Dependent fields
+        * @return {Function} return.1 Test function
         */
        function hideIfParse( $el, spec ) {
                var op, i, l, v, $field, $fields, fields, func, funcs, getVal;
@@ -63,7 +67,7 @@
                                                throw new Error( op + ' parameters must be arrays' );
                                        }
                                        v = hideIfParse( $el, spec[i] );
-                                       fields.push( v[0] );
+                                       fields = fields.concat( v[0].toArray() );
                                        funcs.push( v[1] );
                                }
                                $fields = $( fields );