Skip to content

Commit

Permalink
Bugfix - have destroy remove it's own event handler. Fixes jackmoore#218
Browse files Browse the repository at this point in the history
.
  • Loading branch information
jackmoore committed Apr 23, 2015
1 parent e73c2bb commit f32d65b
Show file tree
Hide file tree
Showing 6 changed files with 27 additions and 20 deletions.
2 changes: 1 addition & 1 deletion bower.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.0",
"version": "3.0.1",
"dependencies": {},
"keywords": [
"textarea",
Expand Down
21 changes: 12 additions & 9 deletions changelog.md
Original file line number Diff line number Diff line change
@@ -1,25 +1,28 @@
## Changelog

##### v.3.0.1 - 2015-04-23
* Fixed the destroy event so that it removes it's own event handler. Fixes #218.

##### v.3.0.0 - 2015-04-15
* added new methods for updating and destroying:
* Added new methods for updating and destroying:

* autosize.update(elements)
* autosize.destroy(elements)

* renamed custom events as to not use jQuery's custom events namespace:
* Renamed custom events as to not use jQuery's custom events namespace:

* autosize.resized renamed to autosize:resized
* autosize.update renamed to autosize:update
* autosize.destroy renamed to autosize:destroy

##### v.2.0.1 - 2015-04-15
* version bump for NPM publishing purposes
* Version bump for NPM publishing purposes

##### v.2.0.0 - 2015-02-25

* smaller, simplier code-base
* new API. Example usage: `autosize(document.querySelectorAll(textarea));`
* dropped jQuery dependency
* dropped IE7-IE8 support
* dropped optional parameters
* closes #98, closes #106, closes #123, fixes #129, fixes #132, fixes #139, closes #140, closes #166, closes #168, closes #192, closes #193, closes #197
* Smaller, simplier code-base
* New API. Example usage: `autosize(document.querySelectorAll(textarea));`
* Dropped jQuery dependency
* Dropped IE7-IE8 support
* Dropped optional parameters
* Closes #98, closes #106, closes #123, fixes #129, fixes #132, fixes #139, closes #140, closes #166, closes #168, closes #192, closes #193, closes #197
10 changes: 6 additions & 4 deletions dest/autosize.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*!
Autosize 3.0.0
Autosize 3.0.1
license: MIT
http://www.jacklmoore.com/autosize
*/
Expand Down Expand Up @@ -86,12 +86,12 @@
}
}

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

Object.keys(style).forEach(function (key) {
ta.style[key] = style[key];
Expand All @@ -100,7 +100,9 @@
height: ta.style.height,
overflowY: ta.style.overflowY,
resize: ta.style.resize
}));
});

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

// IE9 does not fire onpropertychange or oninput for deletions,
// so binding to onkeyup to catch most of those events.
Expand Down
4 changes: 2 additions & 2 deletions dest/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.0",
"version": "3.0.1",
"keywords": [
"textarea",
"form",
Expand Down
8 changes: 5 additions & 3 deletions src/autosize.js
Original file line number Diff line number Diff line change
Expand Up @@ -66,12 +66,12 @@ function assign(ta) {
}
}

ta.addEventListener('autosize:destroy', style => {
const destroy = style => {
window.removeEventListener('resize', update);
ta.removeEventListener('input', update);
ta.removeEventListener('keyup', update);
ta.removeAttribute('data-autosize-on');
ta.removeEventListener('autosize:destroy');
ta.removeEventListener('autosize:destroy', destroy);

Object.keys(style).forEach(key => {
ta.style[key] = style[key];
Expand All @@ -80,7 +80,9 @@ function assign(ta) {
height: ta.style.height,
overflowY: ta.style.overflowY,
resize: ta.style.resize
}));
});

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

// IE9 does not fire onpropertychange or oninput for deletions,
// so binding to onkeyup to catch most of those events.
Expand Down

0 comments on commit f32d65b

Please sign in to comment.