monospaced/angular-elastic — pull request #19 by richardharrington (2014-06-03 14:18:54+00:00)
Title: makes sure dynamic getComputedStyle returns 'used value' in pixels

When an element is set to "display: none", and it has a percentage width, then that percentage width is returned as a string by window.getComputedValue.getPropertyValue('width'). This can happen in difficult-to-fix race conditions when you have an ng-show directive on the textarea or on one of its parents.

The previous behavior of the adjust function was to run parseInt on the main textarea's percentage width and then apply that number to the width of the mirror textarea with "px" appended to the end, causing weird results. (In our case, it was "96%" when it should have been around "600px", so the directive then ended up making the textarea way too high to accommodate a 96px width.)

Better just to not readjust the width, if it cannot be determined. This fix solved our problem.