Skip to content

Commit

Permalink
Add tentative support for IE8
Browse files Browse the repository at this point in the history
  • Loading branch information
dandv committed Mar 19, 2014
1 parent 4acc467 commit 9cbee62
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ None.

* Add tests.
* Consider adding [IE-specific](http://geekswithblogs.net/svanvliet/archive/2005/03/24/textarea-cursor-position-with-javascript.aspx) [code](http://stackoverflow.com/questions/16212871/get-the-offset-position-of-the-caret-in-a-textarea-in-pixels) if it avoids the necessity of creating the mirror div and might fix #14.
* Test IE8 support with `currentStyle`.

## Implementation notes

Expand Down
6 changes: 3 additions & 3 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ module.exports = function (textarea, position, recalculate) {
document.body.appendChild(div);

var style = div.style;
var computed = getComputedStyle(textarea);
var computed = window.getComputedStyle? getComputedStyle(textarea) : textarea.currentStyle; // currentStyle for IE < 9

// default textarea styles
style.whiteSpace = 'pre-wrap';
Expand Down Expand Up @@ -82,8 +82,8 @@ module.exports = function (textarea, position, recalculate) {
div.appendChild(span);

var coordinates = {
top: span.offsetTop + parseInt(computed['borderTopWidth']), // different ways of accessing computed's members
left: span.offsetLeft + parseInt(computed.getPropertyValue('border-left-width'))
top: span.offsetTop + parseInt(computed['borderTopWidth']),
left: span.offsetLeft + parseInt(computed['borderLeftWidth'])
};

document.body.removeChild(div);
Expand Down

0 comments on commit 9cbee62

Please sign in to comment.