Skip to content

Commit

Permalink
cleanup. removed lines that set wordWrap and overflow style property …
Browse files Browse the repository at this point in the history
…values, as these are no longer needed as of v2.0.
  • Loading branch information
jackmoore committed Apr 14, 2015
1 parent 78a1b26 commit b871844
Showing 1 changed file with 11 additions and 21 deletions.
32 changes: 11 additions & 21 deletions src/autosize.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,6 @@
ta.style.resize = 'horizontal';
}

// horizontal overflow is hidden, so break-word is necessary for handling words longer than the textarea width
ta.style.wordWrap = 'break-word';

// Chrome/Safari-specific fix:
// When the textarea y-overflow is hidden, Chrome/Safari doesn't reflow the text to account for the space
// made available by removing the scrollbar. This workaround will cause the text to reflow.
Expand Down Expand Up @@ -85,41 +82,34 @@
}
}

// IE9 does not fire onpropertychange or oninput for deletions,
// so binding to onkeyup to catch most of those events.
// There is no way that I know of to detect something like 'cut' in IE9.
if ('onpropertychange' in ta && 'oninput' in ta) {
ta.addEventListener('keyup', adjust);
}

window.addEventListener('resize', adjust);
ta.addEventListener('input', adjust);

ta.addEventListener('autosize.update', adjust);

ta.addEventListener('autosize.destroy', function(style){
window.removeEventListener('resize', adjust);
ta.removeEventListener('input', adjust);
ta.removeEventListener('keyup', adjust);
ta.removeAttribute('data-autosize-on');
ta.removeEventListener('autosize.destroy');

Object.keys(style).forEach(function(key){
ta.style[key] = style[key];
});

ta.removeAttribute('data-autosize-on');
}.bind(ta, {
height: ta.style.height,
overflow: ta.style.overflow,
overflowY: ta.style.overflowY,
wordWrap: ta.style.wordWrap,
resize: ta.style.resize
}));

// IE9 does not fire onpropertychange or oninput for deletions,
// so binding to onkeyup to catch most of those events.
// There is no way that I know of to detect something like 'cut' in IE9.
if ('onpropertychange' in ta && 'oninput' in ta) {
ta.addEventListener('keyup', adjust);
}

window.addEventListener('resize', adjust);
ta.addEventListener('input', adjust);
ta.addEventListener('autosize.update', adjust);
ta.setAttribute('data-autosize-on', true);
ta.style.overflow = 'hidden';
ta.style.overflowY = 'hidden';

init();
}

Expand Down

0 comments on commit b871844

Please sign in to comment.