Textarea autoexpander code hangs up on some machines

corylulu

New Member
I use it in my TB add-on. I believe that this bug affects no more than 20% of user machines. There are only 3 users who reported this bug. Main problem is that I cannot reproduce it on my machine. \[code\](function($){ $.fn.inputexpander = function (settings) { var config = { classmodifier: "tae" }; if (settings) { $.extend(config, settings); } function CheckContent(element) { if (element.clientHeight < element.scrollHeight){ var $elem = $(element); var height = $elem.height() + 5; $elem.height(element.scrollHeight+5); CheckContent(element); } } return this.each(function () { $(this).addClass(config.classmodifier).css({ overflow: "hidden" }); $(this).bind("keyup", function () { CheckContent(this); }); });};})(jQuery);\[/code\]I bind it as follows:\[code\]$('textarea').inputexpander();\[/code\]As I understand, the condition \[code\] element.clientHeight < element.scrollHeight\[/code\]gets calculate always true. It leads to endless recursion and 5 seconds hangup (reported by user). Then TB gives up and stops the script. May be element.clientHeight is always null, may be something else....Any ideas how to make it work everywhere?
 
Back
Top