* (bug 29804) Fix byte-length-limited fields to check the length of to-be-added char...
authorBrion Vibber <brion@users.mediawiki.org>
Mon, 11 Jul 2011 17:53:52 +0000 (17:53 +0000)
committerBrion Vibber <brion@users.mediawiki.org>
Mon, 11 Jul 2011 17:53:52 +0000 (17:53 +0000)
commit08ac8fa7f3d067a5c1cdef93c4e2c8287e5d1436
tree3300091f54c589fd0a5a4b7dce78e4566fe85379
parente6294bfe4d840e669dc058c04fc00fa88b28a95c
* (bug 29804) Fix byte-length-limited fields to check the length of to-be-added char instead of hardcoding a possible length of 3.

Since the Unicode code point of the character being inserted is passed with the keypress event, we can simply turn it into a string and toss it into jquery.byteLength to calculate the length in bytes.

Also fixed a broken test case that had the wrong number of expected chars.

Note that this will probably still not work right in many circumstances -- pastes, anything dealing with selection, and it's entirely possible that individual 'keypress' events might be totally unreliable when dealing with funky input methods.
resources/jquery/jquery.byteLimit.js
tests/qunit/suites/resources/jquery/jquery.byteLimit.js