summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJack Moore <hello@jacklmoore.com>2015-04-23 12:06:20 -0400
committerJack Moore <hello@jacklmoore.com>2015-04-23 12:06:20 -0400
commitf32d65b2e57a8ab354053ffa1cf13015ec2b509e (patch)
tree8971afa0413e09a1d14adcd70d7b2eb3b2f66eab
parente73c2bbe94993b1070c3db0498c1920860c8e38c (diff)
downloadautosize-f32d65b2e57a8ab354053ffa1cf13015ec2b509e.zip
autosize-f32d65b2e57a8ab354053ffa1cf13015ec2b509e.tar.gz
autosize-f32d65b2e57a8ab354053ffa1cf13015ec2b509e.tar.bz2
Bugfix - have destroy remove it's own event handler. Fixes #218.3.0.1
-rw-r--r--bower.json2
-rw-r--r--changelog.md21
-rw-r--r--dest/autosize.js10
-rw-r--r--dest/autosize.min.js4
-rw-r--r--package.json2
-rw-r--r--src/autosize.js8
6 files changed, 27 insertions, 20 deletions
diff --git a/bower.json b/bower.json
index 08968ee..019c286 100644
--- a/bower.json
+++ b/bower.json
@@ -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",
diff --git a/changelog.md b/changelog.md
index ead80cb..da5a802 100644
--- a/changelog.md
+++ b/changelog.md
@@ -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 \ No newline at end of file
+* 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 \ No newline at end of file
diff --git a/dest/autosize.js b/dest/autosize.js
index 4ac4b96..ba062c7 100644
--- a/dest/autosize.js
+++ b/dest/autosize.js
@@ -1,5 +1,5 @@
/*!
- Autosize 3.0.0
+ Autosize 3.0.1
license: MIT
http://www.jacklmoore.com/autosize
*/
@@ -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];
@@ -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.
diff --git a/dest/autosize.min.js b/dest/autosize.min.js
index f4979df..7869c35 100644
--- a/dest/autosize.min.js
+++ b/dest/autosize.min.js
@@ -1,6 +1,6 @@
/*!
- Autosize 3.0.0
+ Autosize 3.0.1
license: MIT
http://www.jacklmoore.com/autosize
*/
-!function(e,t){if("function"==typeof define&&define.amd)define(["exports","module"],t);else if("undefined"!=typeof exports&&"undefined"!=typeof module)t(exports,module);else{var o={exports:{}};t(o.exports,o),e.autosize=o.exports}}(this,function(e,t){"use strict";function o(e){function t(){var t=window.getComputedStyle(e,null);"vertical"===t.resize?e.style.resize="none":"both"===t.resize&&(e.style.resize="horizontal");var r=e.style.width;e.style.width="0px",e.offsetWidth,e.style.width=r,n="none"!==t.maxHeight?parseFloat(t.maxHeight):!1,i="content-box"===t.boxSizing?-(parseFloat(t.paddingTop)+parseFloat(t.paddingBottom)):parseFloat(t.borderTopWidth)+parseFloat(t.borderBottomWidth),o()}function o(){var t=e.style.height,o=document.documentElement.scrollTop,r=document.body.scrollTop;e.style.height="auto";var d=e.scrollHeight+i;if(n!==!1&&d>n?(d=n,"scroll"!==e.style.overflowY&&(e.style.overflowY="scroll")):"hidden"!==e.style.overflowY&&(e.style.overflowY="hidden"),e.style.height=d+"px",document.documentElement.scrollTop=o,document.body.scrollTop=r,t!==e.style.height){var s=document.createEvent("Event");s.initEvent("autosize:resized",!0,!1),e.dispatchEvent(s)}}if(e&&e.nodeName&&"TEXTAREA"===e.nodeName&&!e.hasAttribute("data-autosize-on")){var n,i;e.addEventListener("autosize:destroy",function(t){window.removeEventListener("resize",o),e.removeEventListener("input",o),e.removeEventListener("keyup",o),e.removeAttribute("data-autosize-on"),e.removeEventListener("autosize:destroy"),Object.keys(t).forEach(function(o){e.style[o]=t[o]})}.bind(e,{height:e.style.height,overflowY:e.style.overflowY,resize:e.style.resize})),"onpropertychange"in e&&"oninput"in e&&e.addEventListener("keyup",o),window.addEventListener("resize",o),e.addEventListener("input",o),e.addEventListener("autosize:update",o),e.setAttribute("data-autosize-on",!0),e.style.overflowY="hidden",t()}}function n(e){if(e&&e.nodeName&&"TEXTAREA"===e.nodeName){var t=document.createEvent("Event");t.initEvent("autosize:destroy",!0,!1),e.dispatchEvent(t)}}function i(e){if(e&&e.nodeName&&"TEXTAREA"===e.nodeName){var t=document.createEvent("Event");t.initEvent("autosize:update",!0,!1),e.dispatchEvent(t)}}var r;"function"!=typeof window.getComputedStyle?(r=function(e){return e},r.destroy=function(e){return e},r.update=function(e){return e}):(r=function(e){return e&&e.length?Array.prototype.forEach.call(e,o):e&&e.nodeName&&o(e),e},r.destroy=function(e){return e&&e.length?Array.prototype.forEach.call(e,n):e&&e.nodeName&&n(e),e},r.update=function(e){return e&&e.length?Array.prototype.forEach.call(e,i):e&&e.nodeName&&i(e),e}),t.exports=r}); \ No newline at end of file
+!function(e,t){if("function"==typeof define&&define.amd)define(["exports","module"],t);else if("undefined"!=typeof exports&&"undefined"!=typeof module)t(exports,module);else{var o={exports:{}};t(o.exports,o),e.autosize=o.exports}}(this,function(e,t){"use strict";function o(e){function t(){var t=window.getComputedStyle(e,null);"vertical"===t.resize?e.style.resize="none":"both"===t.resize&&(e.style.resize="horizontal");var r=e.style.width;e.style.width="0px",e.offsetWidth,e.style.width=r,n="none"!==t.maxHeight?parseFloat(t.maxHeight):!1,i="content-box"===t.boxSizing?-(parseFloat(t.paddingTop)+parseFloat(t.paddingBottom)):parseFloat(t.borderTopWidth)+parseFloat(t.borderBottomWidth),o()}function o(){var t=e.style.height,o=document.documentElement.scrollTop,r=document.body.scrollTop;e.style.height="auto";var d=e.scrollHeight+i;if(n!==!1&&d>n?(d=n,"scroll"!==e.style.overflowY&&(e.style.overflowY="scroll")):"hidden"!==e.style.overflowY&&(e.style.overflowY="hidden"),e.style.height=d+"px",document.documentElement.scrollTop=o,document.body.scrollTop=r,t!==e.style.height){var s=document.createEvent("Event");s.initEvent("autosize:resized",!0,!1),e.dispatchEvent(s)}}if(e&&e.nodeName&&"TEXTAREA"===e.nodeName&&!e.hasAttribute("data-autosize-on")){var n,i,r=function(t){window.removeEventListener("resize",o),e.removeEventListener("input",o),e.removeEventListener("keyup",o),e.removeAttribute("data-autosize-on"),e.removeEventListener("autosize:destroy",r),Object.keys(t).forEach(function(o){e.style[o]=t[o]})}.bind(e,{height:e.style.height,overflowY:e.style.overflowY,resize:e.style.resize});e.addEventListener("autosize:destroy",r),"onpropertychange"in e&&"oninput"in e&&e.addEventListener("keyup",o),window.addEventListener("resize",o),e.addEventListener("input",o),e.addEventListener("autosize:update",o),e.setAttribute("data-autosize-on",!0),e.style.overflowY="hidden",t()}}function n(e){if(e&&e.nodeName&&"TEXTAREA"===e.nodeName){var t=document.createEvent("Event");t.initEvent("autosize:destroy",!0,!1),e.dispatchEvent(t)}}function i(e){if(e&&e.nodeName&&"TEXTAREA"===e.nodeName){var t=document.createEvent("Event");t.initEvent("autosize:update",!0,!1),e.dispatchEvent(t)}}var r;"function"!=typeof window.getComputedStyle?(r=function(e){return e},r.destroy=function(e){return e},r.update=function(e){return e}):(r=function(e){return e&&e.length?Array.prototype.forEach.call(e,o):e&&e.nodeName&&o(e),e},r.destroy=function(e){return e&&e.length?Array.prototype.forEach.call(e,n):e&&e.nodeName&&n(e),e},r.update=function(e){return e&&e.length?Array.prototype.forEach.call(e,i):e&&e.nodeName&&i(e),e}),t.exports=r}); \ No newline at end of file
diff --git a/package.json b/package.json
index bdc3f32..fe6d0c2 100644
--- a/package.json
+++ b/package.json
@@ -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",
diff --git a/src/autosize.js b/src/autosize.js
index 62d0ab1..02621ab 100644
--- a/src/autosize.js
+++ b/src/autosize.js
@@ -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];
@@ -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.