[webkit-dev] Newline translation issue with textareas

Kevin Ballard kevin at sb.org
Sun Jun 19 12:22:34 PDT 2005


For a quick test of the newline translation problem I was talking  
about, try this code. Press the first button to get a count of the  
characters in the field, and the second to replace the contents of  
the field with the same text but using \r\n instead of \n as newline.  
So render this in WebKit, press the first button to get a count of  
12, press the second button to modify the field, press the first to  
get a count of 14, then manually modify the field (i.e. type a  
character and delete it) and press the first button and you'll get a  
count of 12 again. The correct behaviour, I believe, is to always  
return a count of 12, and if you test this in Firefox you'll see  
that's what happens there.

<html>
     <head>
         <title>foo</title>
         <script type="text/javascript">
function foobar() {
     var textarea = document.getElementById("foo");
     alert(textarea.value.length);
}
function bar() {
     var textarea = document.getElementById("foo");
     //textarea.setSelectionRange(3,7);
     textarea.value = "A\r\ntext\r\nfield";
     textarea.focus();
}
         </script>
     </head>
     <body>
         <p>Test</p>
         <form>
             <textarea id="foo">A
text
field</textarea>
             <br />
             <input type="submit" onclick="foobar(); return false;"  
value="Length" />
             <br />
             <input type="submit" onclick="bar(); return false;"  
value="Modify" />
         </form>
     </body>
</html>


-- 
Kevin Ballard
kevin at sb.org
http://www.tildesoft.com
http://kevin.sb.org

-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/pkcs7-signature
Size: 2378 bytes
Desc: not available
Url : http://lists.macosforge.org/pipermail/webkit-dev/attachments/20050619/a3d498f1/smime.bin


More information about the webkit-dev mailing list