Skip to content

Commit

Permalink
Update feature detection to account for browsers that do not fire syn…
Browse files Browse the repository at this point in the history
…thetic events on disabled elements
  • Loading branch information
ccummings committed Mar 28, 2017
1 parent cd6d40a commit 36d1c48
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions dom/events/events.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ module.exports = {
return (this.nodeName && (this.nodeType === 1 || this.nodeType === 9)) || this === window;
},
dispatch: function(event, args, bubbles){
console.log('dispatch', this.tagName, event);
var doc = _document();
var ret;
var dispatchingOnDisabled = fixSyntheticEventsOnDisabled && isDispatchingOnDisabled(this, event);
Expand All @@ -54,14 +55,22 @@ module.exports = {
};

// In FireFox, dispatching a synthetic event on a disabled element throws an error.
// Other browsers, like IE 10 do not dispatch synthetic events on disabled elements at all.
// This determines if we have to work around that when dispatching events.
// https://bugzilla.mozilla.org/show_bug.cgi?id=329509
(function() {
var input = document.createElement("input");
input.disabled = true;
var timer = setTimeout(function() {
fixSyntheticEventsOnDisabled = true;
}, 50);
module.exports.addEventListener.call(input, 'foo', function(){
clearTimeout(timer);
});
try {
module.exports.dispatch.call(input, 'foo', [], false);
} catch(e) {
clearTimeout(timer);
fixSyntheticEventsOnDisabled = true;
}
})();

0 comments on commit 36d1c48

Please sign in to comment.