mediawiki.htmlform: Refactor and clean up
authorTimo Tijhof <krinklemail@gmail.com>
Fri, 9 May 2014 08:44:34 +0000 (10:44 +0200)
committerTimo Tijhof <krinklemail@gmail.com>
Mon, 19 May 2014 17:29:46 +0000 (19:29 +0200)
commitdaa92bb06e26d2c05d76f1b5926fcf853a9fb892
treef26b4ce6bcf917b6e182aea4df25f249788a7ed4
parent05846af6d1a62e8c0750a17b900a3be7448a3a47
mediawiki.htmlform: Refactor and clean up

* Use .filter function instead of concatenating strings.
  The end result is the same.

  It's faster and more stable and semantically correct this way
  because using the string syntax is subject to bugs when using
  special characters (you'd have to escape it first, which is
  non-trivial to do in CSS selectors, sometimes impossible).
  So comparing the .name property against a string value directly
  is much easier.

* Use .prop() instead of .attr() where appropiate.
  attr() changes attribute nodes only in the DOM, properties
  reflect the actual live rendered value. This works because of
  a back-compat layer in jQuery, but has been deprecated.

* Use a simple array and create 1 jQuery object, instead of
  creating various temporary objects only to have jQuery merge
  them via .add(). .add() is relatively expensive in that it
  keeps a reference in pushStack and does a lot of logic. Fine
  for convenience, but since we have all the data right here,
  might as well take a more direct approach.

* Remove ill-informed $() calls. This is already a jQuery object
  for the method is a jQuery method. Cloning the object first
  leads to unexpected side-effects and is simply not neccecary.

* Remove use of .live()

Change-Id: Icfe63a4111026661c53639b72e67a4d4fa3d6ac2
resources/src/mediawiki/mediawiki.htmlform.js