Only one issue to resolve to add support for IE 7 and 8
Closed this issue · 11 comments
Please read the article here: http://www.sitepoint.com/line-endings-in-javascript/
I cannot seem to get rid of the \r\n line ending in javascript.
The issue: On IE 7 and 8, a single newline has a length of 2 if within a textarea. Throws everything off.
SitePoint goes over a way around this but I cannot figure a way to implement this.
EDIT: More information
Setting the Caret position is OK, retrieving the actual value is wrong, see here:
I have setup a fiddle of the demo to start playing with this:
My bad. I assumed jsfiddle worked with IE8. I loaded the fiddle in VirtualBox (I'm on OSX) and discovered it does not. Sorry about that.
No, it's all good.
Currently, I am thinking of an approach by measuring the newline characters length and then offsetting the carat get/sets by appropriate amounts, but it's still really tricky.
Cool and good luck. Nice work on this by-the-way. I love it.
What exactly is your problem with the different line breaks?
@Paratron The issue is IE 7/8 use \n\r as a line break instead of \n. So if you were to press enter on an empty textarea, you'd expect the values length to be one, but IE7/8 has a value of 2. This messes things up all around.
I was thinking about stripping the \r via the utils.editor.get method, but still, when I set everything, (data and carat), the carat is set in the wrong place.
@jakiestfu I have a partially working fix in my fork, but utils.cursor.set is still causing issues. I have the tab and multiline tab working properly.
@birla I see you're trying to fix the get caret issue.
I tried implementing it in a much simpler fashion, and it still did not work. Try messing with this fiddle and see if you can figure out how to fix this! Thanks for your help!
@jakiestfu I took a shot at the fiddle and I was able to fix getting the caret position in all cases except when it's at the beginning of a new line.
@birla http://jsfiddle.net/jakie8/kreQP/5/
Type in a brace (which should give you an open and close), then keep pressing enter. For every time you press enter, the cursor's get position is incremented by one. I believe fixing that would also fix the issue with it at the newline. Any ideas? Thanks so much for your help!
I have completed _full support_ for IE 7 and 8. Will push later tonight after cleaning it up a bit. Thanks for all of your help everyone!