Skip to content

Commit

Permalink
Fixed memory leak on destroy, fixes jackmoore#270.
Browse files Browse the repository at this point in the history
Fixed bug in old versions of Firefox (1-5), fixes jackmoore#246.
  • Loading branch information
jackmoore committed Nov 11, 2015
1 parent 2b9d32f commit 97a0f84
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 23 deletions.
4 changes: 4 additions & 0 deletions changelog.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
## Changelog

##### v.3.0.14 - 2015-11-11
* Fixed memory leak on destroy. Merged #271, fixes #270.
* Fixed bug in old versions of Firefox (1-5), fixes #246.

##### v.3.0.13 - 2015-09-26
* Fixed scroll-bar jumpiness in iOS. Merged #261, fixes #207.
* Fixed reflowing of initial text in Chrome and Safari.
Expand Down
21 changes: 11 additions & 10 deletions dist/autosize.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*!
Autosize 3.0.13
Autosize 3.0.14
license: MIT
http://www.jacklmoore.com/autosize
*/
Expand Down Expand Up @@ -150,10 +150,11 @@
};

var destroy = (function (style) {
window.removeEventListener('resize', pageResize);
ta.removeEventListener('input', update);
ta.removeEventListener('keyup', update);
ta.removeEventListener('autosize:destroy', destroy);
window.removeEventListener('resize', pageResize, false);
ta.removeEventListener('input', update, false);
ta.removeEventListener('keyup', update, false);
ta.removeEventListener('autosize:destroy', destroy, false);
ta.removeEventListener('autosize:update', update, false);
set['delete'](ta);

Object.keys(style).forEach(function (key) {
Expand All @@ -166,18 +167,18 @@
overflowX: ta.style.overflowX,
wordWrap: ta.style.wordWrap });

ta.addEventListener('autosize:destroy', destroy);
ta.addEventListener('autosize:destroy', destroy, false);

// 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', update);
ta.addEventListener('keyup', update, false);
}

window.addEventListener('resize', pageResize);
ta.addEventListener('input', update);
ta.addEventListener('autosize:update', update);
window.addEventListener('resize', pageResize, false);
ta.addEventListener('input', update, false);
ta.addEventListener('autosize:update', update, false);
set.add(ta);

if (setOverflowX) {
Expand Down
4 changes: 2 additions & 2 deletions dist/autosize.min.js

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

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "autosize",
"description": "Autosize is a small, stand-alone script to automatically adjust textarea height to fit text.",
"version": "3.0.13",
"version": "3.0.14",
"keywords": [
"textarea",
"form",
Expand Down
20 changes: 10 additions & 10 deletions src/autosize.js
Original file line number Diff line number Diff line change
Expand Up @@ -124,11 +124,11 @@ function assign(ta, {setOverflowX = true, setOverflowY = true} = {}) {
};

const destroy = style => {
window.removeEventListener('resize', pageResize);
ta.removeEventListener('input', update);
ta.removeEventListener('keyup', update);
ta.removeEventListener('autosize:destroy', destroy);
ta.removeEventListener('autosize:update', update);
window.removeEventListener('resize', pageResize, false);
ta.removeEventListener('input', update, false);
ta.removeEventListener('keyup', update, false);
ta.removeEventListener('autosize:destroy', destroy, false);
ta.removeEventListener('autosize:update', update, false);
set.delete(ta);

Object.keys(style).forEach(key => {
Expand All @@ -142,18 +142,18 @@ function assign(ta, {setOverflowX = true, setOverflowY = true} = {}) {
wordWrap: ta.style.wordWrap,
});

ta.addEventListener('autosize:destroy', destroy);
ta.addEventListener('autosize:destroy', destroy, false);

// 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', update);
ta.addEventListener('keyup', update, false);
}

window.addEventListener('resize', pageResize);
ta.addEventListener('input', update);
ta.addEventListener('autosize:update', update);
window.addEventListener('resize', pageResize, false);
ta.addEventListener('input', update, false);
ta.addEventListener('autosize:update', update, false);
set.add(ta);

if (setOverflowX) {
Expand Down

0 comments on commit 97a0f84

Please sign in to comment.