+
+ map.delete(ta);
+ }).bind(ta, {
+ height: ta.style.height,
+ resize: ta.style.resize,
+ overflowY: ta.style.overflowY,
+ overflowX: ta.style.overflowX,
+ wordWrap: ta.style.wordWrap,
+ });
+
+ 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, false);
+ }
+
+ window.addEventListener('resize', pageResize, false);
+ ta.addEventListener('input', update, false);
+ ta.addEventListener('autosize:update', update, false);
+ ta.style.overflowX = 'hidden';
+ ta.style.wordWrap = 'break-word';
+
+ map.set(ta, {
+ destroy,
+ update,
+ });
+
+ init();
+}
+
+function destroy(ta) {
+ const methods = map.get(ta);
+ if (methods) {
+ methods.destroy();
+ }
+}
+
+function update(ta) {
+ const methods = map.get(ta);
+ if (methods) {
+ methods.update();
+ }
+}
+
+let autosize = null;
+
+// Do nothing in Node.js environment and IE8 (or lower)
+if (typeof window === 'undefined' || typeof window.getComputedStyle !== 'function') {
+ autosize = el => el;
+ autosize.destroy = el => el;
+ autosize.update = el => el;
+} else {
+ autosize = (el, options) => {
+ if (el) {
+ Array.prototype.forEach.call(el.length ? el : [el], x => assign(x, options));
+ }
+ return el;
+ };
+ autosize.destroy = el => {
+ if (el) {
+ Array.prototype.forEach.call(el.length ? el : [el], destroy);
+ }
+ return el;