Skip to content

Commit

Permalink
Only set white-space on mirrored div for textareas
Browse files Browse the repository at this point in the history
  • Loading branch information
Jeff S committed Feb 18, 2019
1 parent b5845a4 commit 3be9314
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ var properties = [
'textDecoration', // might not make a difference, but better be safe

'letterSpacing',
'whiteSpace',
'wordSpacing',

'tabSize',
Expand Down Expand Up @@ -72,9 +73,10 @@ function getCaretCoordinates(element, position, options) {
var isInput = element.nodeName === 'INPUT';

// Default textarea styles
style.whiteSpace = 'pre-wrap';
if (!isInput)
if (!isInput) {
style.whiteSpace = 'pre-wrap';
style.wordWrap = 'break-word'; // only for textarea-s
}

// Position off-screen
style.position = 'absolute'; // required to return coordinates properly
Expand Down

0 comments on commit 3be9314

Please sign in to comment.