Safari Textarea bug

Well, I came across another Safari bug dealing with forms today. Unfortunately, I discovered this problem months ago and compeltely forgot it. So I figured I should document the issue so when it arises again, I won’t waste any time searching for the solution.

Basically, like most other issues with forms on IE and Safari, this issue deals with setting values of elements before they are on the document. Before today, I thought that checkboxes and radios in IE were the main problem, but textareas also have issues.

Here is the hack I did to solve the problem:

//While populating the form
var form = Element.createHtml('<form><textarea name="some_textarea"></textarea></form>');
form.some_textarea.value =
    form.some_textarea._value = 'Hello world';

//When appending the form to the document
document.body.appendChild(form);

//Safari fix
form.some_textarea.value = form.some_textarea._value;

If I am feeling chipper, I may even search through WebKit’s huge list of bugs to see if it needs to be reported. Hope this helps someone out there.