(bug 36310) jquery.byteLimit should skip < 0 due to Firefox bug.
authorTimo Tijhof <ttijhof@wikimedia.org>
Fri, 22 Jun 2012 20:16:18 +0000 (22:16 +0200)
committerTimo Tijhof <ttijhof@wikimedia.org>
Fri, 22 Jun 2012 20:16:18 +0000 (22:16 +0200)
commit126437076ca25a5aba3c53112b76e92e48368ca3
tree5cad1f4a54fdb0433302a4d489c7cd29da7bc2b3
parenta97f6b035c951e16c385ca85169fd7d7578f2af8
(bug 36310) jquery.byteLimit should skip < 0 due to Firefox bug.

* Firefox returns -1 if an element has no maxLength property set.
  (instead of undefined). This is especially problematic because
  roundtripping that value (e.g. setting elem.maxLength = -1;)
  causes a DOMException to be thrown.
  That exception is expected (and happens also in Chrome), but Chrome
  and other standard browsers don't return -1 for the getter, so it
  would never end up in the setter.

* Moved the check to before the property set/removal. Otherwise
  the exception would still be thrown. This should've been before
  anyway.

* This fixes:
  - (bug 36310) Can't enter a log summary on Special:MovePage
  in Firefox.

  Even though we do set maxLength for that field from PHP. Recently
  the input field was changed from <input> to <textarea>. And since
  English Wikipedia has wgHtml5 disabled and maxLength on <textarea>
  is new in HTML5, that property was stripped by the Html class, and
  the javascript incorrectly assumed  that the property would be there
  and thus caused the DOMException in Firefox.

* Added unit test for this (which fails in Firefox without this fix).

Change-Id: I28490b61bd5a20dd1d84c4730615514d3822aa77
resources/jquery/jquery.byteLimit.js
tests/qunit/suites/resources/jquery/jquery.byteLimit.test.js