Skip to content

Commit

Permalink
Removed data attribute as a way of tracking which elements autosize h…
Browse files Browse the repository at this point in the history
…as been assigned to. fixes jackmoore#254, fixes jackmoore#200.
  • Loading branch information
jackmoore committed Sep 10, 2015
1 parent d40e474 commit 08d62d0
Show file tree
Hide file tree
Showing 6 changed files with 45 additions and 11 deletions.
2 changes: 1 addition & 1 deletion build.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ function lint(full) {
eqeqeq: true,
eqnull: true,
noarg: true,
predef: ['define', 'module', 'exports']
predef: ['define', 'module', 'exports', 'Set']
});

if (jshint.errors.length) {
Expand Down
3 changes: 3 additions & 0 deletions changelog.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
## Changelog

##### v.3.0.10 - 2015-09-10
* Removed data attribute as a way of tracking which elements autosize has been assigned to. fixes #254, fixes #200.

##### v.3.0.9 - 2015-09-02
* Fixed issue with assigning autosize to detached nodes. Merged #253, Fixes #234.

Expand Down
23 changes: 19 additions & 4 deletions dist/autosize.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*!
Autosize 3.0.9
Autosize 3.0.10
license: MIT
http://www.jacklmoore.com/autosize
*/
Expand All @@ -18,6 +18,21 @@
})(this, function (exports, module) {
'use strict';

var set = Set ? new Set() : (function () {
var list = [];

return {
has: function has(key) {
return Boolean(list.indexOf(key) > -1);
},
add: function add(key) {
list.push(key);
},
'delete': function _delete(key) {
list.splice(list.indexOf(key), 1);
} };
})();

function assign(ta) {
var _ref = arguments[1] === undefined ? {} : arguments[1];

Expand All @@ -26,7 +41,7 @@
var _ref$setOverflowY = _ref.setOverflowY;
var setOverflowY = _ref$setOverflowY === undefined ? true : _ref$setOverflowY;

if (!ta || !ta.nodeName || ta.nodeName !== 'TEXTAREA' || ta.hasAttribute('data-autosize-on')) return;
if (!ta || !ta.nodeName || ta.nodeName !== 'TEXTAREA' || set.has(ta)) return;

var heightOffset = null;
var overflowY = 'hidden';
Expand Down Expand Up @@ -126,8 +141,8 @@
window.removeEventListener('resize', update);
ta.removeEventListener('input', update);
ta.removeEventListener('keyup', update);
ta.removeAttribute('data-autosize-on');
ta.removeEventListener('autosize:destroy', destroy);
set['delete'](ta);

Object.keys(style).forEach(function (key) {
ta.style[key] = style[key];
Expand All @@ -151,7 +166,7 @@
window.addEventListener('resize', update);
ta.addEventListener('input', update);
ta.addEventListener('autosize:update', update);
ta.setAttribute('data-autosize-on', true);
set.add(ta);

if (setOverflowY) {
ta.style.overflowY = 'hidden';
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.9",
"version": "3.0.10",
"keywords": [
"textarea",
"form",
Expand Down
22 changes: 19 additions & 3 deletions src/autosize.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,21 @@
var set = Set ? new Set() : (()=>{
const list = [];

return {
has(key) {
return Boolean(list.indexOf(key) > -1);
},
add(key) {
list.push(key);
},
delete(key) {
list.splice(list.indexOf(key), 1);
},
}
})();

function assign(ta, {setOverflowX = true, setOverflowY = true} = {}) {
if (!ta || !ta.nodeName || ta.nodeName !== 'TEXTAREA' || ta.hasAttribute('data-autosize-on')) return;
if (!ta || !ta.nodeName || ta.nodeName !== 'TEXTAREA' || set.has(ta)) return;

let heightOffset = null;
let overflowY = 'hidden';
Expand Down Expand Up @@ -99,8 +115,8 @@ function assign(ta, {setOverflowX = true, setOverflowY = true} = {}) {
window.removeEventListener('resize', update);
ta.removeEventListener('input', update);
ta.removeEventListener('keyup', update);
ta.removeAttribute('data-autosize-on');
ta.removeEventListener('autosize:destroy', destroy);
set.delete(ta);

Object.keys(style).forEach(key => {
ta.style[key] = style[key];
Expand All @@ -125,7 +141,7 @@ function assign(ta, {setOverflowX = true, setOverflowY = true} = {}) {
window.addEventListener('resize', update);
ta.addEventListener('input', update);
ta.addEventListener('autosize:update', update);
ta.setAttribute('data-autosize-on', true);
set.add(ta);

if (setOverflowY) {
ta.style.overflowY = 'hidden';
Expand Down

0 comments on commit 08d62d0

Please sign in to comment.