Fix bug in jquery.byteLimit.js for Safari 4
authorKrinkle <krinkle@users.mediawiki.org>
Fri, 12 Aug 2011 20:34:23 +0000 (20:34 +0000)
committerKrinkle <krinkle@users.mediawiki.org>
Fri, 12 Aug 2011 20:34:23 +0000 (20:34 +0000)
commite30c3a7bb51f69739fef461429c93c27a516c171
tree62be33a59ad38cf4f72cfa3f1d287e08513e7ebc
parent17289de2dbce04cb89b9635f4f582cc9291bf350
Fix bug in jquery.byteLimit.js for Safari 4
* Browsers should ignore the maxLength when the .value is set manually through JavaScript, but for some reason Safari 4 (not 5 and later) is enforcing the limit even when the value property is set from JavaScript. Usually this bug doesn't become visible in this module because the byteLength can't be lower than the number of characters, so we'd never see the bug. However since r94066 we're supporting callbacks, and callbacks could do anything to the calculation, including but not limited to making the string that is being checked shorter (ie. suppose maxLength/byteLimit is 8, value is 'User:Sam', and callback filters like "return new mw.Title(val).getName()". If we set it to 'User:Samp' (+p) then Safari 4 would chop the value, because the total string is longer than 8. Whereas all other browsers ignore maxLength (like they should) and let it be and would allow our callback to happen and instead give byteLimit 'Samp' which is length 4 and we still have 4 more characters to go until we reach 8.

The fix is easy, simply do not set the maxLength property if there's a callback.
resources/jquery/jquery.byteLimit.js