Skip to content

Commit

Permalink
Make events bubble
Browse files Browse the repository at this point in the history
  • Loading branch information
antriver committed Nov 22, 2016
1 parent fa2fa30 commit efb1f0d
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 13 deletions.
26 changes: 15 additions & 11 deletions dist/autosize.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
})(this, function (exports, module) {
'use strict';

var map = typeof Map === 'function' ? new Map() : (function () {
var map = typeof Map === "function" ? new Map() : (function () {
var keys = [];
var values = [];

Expand All @@ -41,11 +41,12 @@
keys.splice(index, 1);
values.splice(index, 1);
}
} };
}
};
})();

var createEvent = function createEvent(name) {
return new Event(name);
return new Event(name, { bubbles: true });
};
try {
new Event('test');
Expand Down Expand Up @@ -113,7 +114,8 @@
if (el.parentNode.scrollTop) {
arr.push({
node: el.parentNode,
scrollTop: el.parentNode.scrollTop });
scrollTop: el.parentNode.scrollTop
});
}
el = el.parentNode;
}
Expand Down Expand Up @@ -176,7 +178,10 @@
var evt = createEvent('autosize:resized');
try {
ta.dispatchEvent(evt);
} catch (err) {}
} catch (err) {
// Firefox will throw an error on dispatchEvent for a detached element
// https://bugzilla.mozilla.org/show_bug.cgi?id=889376
}
}
}

Expand All @@ -203,7 +208,8 @@
resize: ta.style.resize,
overflowY: ta.style.overflowY,
overflowX: ta.style.overflowX,
wordWrap: ta.style.wordWrap });
wordWrap: ta.style.wordWrap
});

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

Expand All @@ -222,7 +228,8 @@

map.set(ta, {
destroy: destroy,
update: update });
update: update
});

init();
}
Expand Down Expand Up @@ -278,7 +285,4 @@
}

module.exports = autosize;
});

// Firefox will throw an error on dispatchEvent for a detached element
// https://bugzilla.mozilla.org/show_bug.cgi?id=889376
});
2 changes: 1 addition & 1 deletion 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 src/autosize.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ const map = (typeof Map === "function") ? new Map() : (function () {
}
})();

let createEvent = (name)=> new Event(name);
let createEvent = (name)=> new Event(name, {bubbles: true});
try {
new Event('test');
} catch(e) {
Expand Down

0 comments on commit efb1f0d

Please sign in to comment.