Skip to content

Commit

Permalink
Fixed a compatability issue with jQuery versions before 1.9 introduce…
Browse files Browse the repository at this point in the history
…d in the previous update (Fixes jackmoore#82)
  • Loading branch information
jackmoore committed Jun 13, 2013
1 parent 3343718 commit e957403
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 14 deletions.
2 changes: 1 addition & 1 deletion autosize.jquery.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"textarea",
"ui"
],
"version": "1.16.16",
"version": "1.16.17",
"author": {
"name": "Jack Moore",
"url": "http://www.jacklmoore.com",
Expand Down
2 changes: 1 addition & 1 deletion component.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "jquery-autosize",
"version": "1.16.16",
"version": "1.16.17",
"main": "./jquery.autosize.js",
"dependencies": {
"jquery": ">=1.7"
Expand Down
6 changes: 3 additions & 3 deletions jquery.autosize-min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

16 changes: 7 additions & 9 deletions jquery.autosize.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/*!
jQuery Autosize v1.16.16
jQuery Autosize v1.16.17
(c) 2013 Jack Moore - jacklmoore.com
updated: 2013-06-11
updated: 2013-06-12
license: http://www.opensource.org/licenses/mit-license.php
*/
(function ($) {
Expand All @@ -15,7 +15,7 @@
hidden = 'hidden',
borderBox = 'border-box',
lineHeight = 'lineHeight',
useSubpixels,
useSubpixels = window.getComputedStyle !== undefined,

// border:0 is unnecessary, but avoids a bug in FireFox on OSX
copy = '<textarea tabindex="-1" style="position:absolute; top:-999px; left:0; right:auto; bottom:auto; border:0; -moz-box-sizing:content-box; -webkit-box-sizing:content-box; box-sizing:content-box; word-wrap:break-word; height:0 !important; min-height:0 !important; overflow:hidden; transition:none; -webkit-transition:none; -moz-transition:none;"/>',
Expand Down Expand Up @@ -47,9 +47,6 @@
}
mirror.style.lineHeight = '';

// test for subpixel rendering
useSubpixels = mirror.getBoundingClientRect().width !== undefined;

$.fn.autosize = function (options) {
options = $.extend({}, defaults, options || {});

Expand Down Expand Up @@ -115,7 +112,7 @@
// Using mainly bare JS in this function because it is going
// to fire very often while typing, and needs to very efficient.
function adjust() {
var height, overflow, original, width;
var height, overflow, original, width, style;

if (mirrored !== ta) {
initMirror();
Expand All @@ -126,10 +123,11 @@
original = parseInt(ta.style.height,10);

if (useSubpixels) {
style = window.getComputedStyle(ta);
// The mirror width much exactly match the textarea width, so using getBoundingClientRect because it doesn't round the subpixel value.
width = ta.getBoundingClientRect().width;
$.each($(ta).css(['paddingLeft', 'paddingRight', 'borderLeftWidth', 'borderRightWidth']), function(){
width -= parseInt(this, 10);
$.each(['paddingLeft', 'paddingRight', 'borderLeftWidth', 'borderRightWidth'], function(i,property){
width -= parseInt(style[property], 10);
});
mirror.style.width = width + 'px';
}
Expand Down
3 changes: 3 additions & 0 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@ Small jQuery plugin to allow dynamic resizing of textarea height, so that it gro

## Changelog

### v1.16.17 - 2013/6/12
* Fixed a compatability issue with jQuery versions before 1.9 introduced in the previous update.

### v1.16.16 - 2013/6/11
* Fixed an issue where the calculated height might be slightly off in modern browsers when the width of the textarea has a subpixel value.

Expand Down

0 comments on commit e957403

Please sign in to comment.