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 b061ba2
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
8 changes: 8 additions & 0 deletions dom/events/events.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,14 +54,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;
}
})();
2 changes: 1 addition & 1 deletion dom/events/inserted/inserted-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ function runTest(name, MUT_OBS) {
// There is a setTimeout, 0 in the non-mutation observer code path
setTimeout(function(){
domMutate.appendChild.call(document.getElementById("qunit-fixture"), input);
}, 20);
}, 50);
});
asyncTest("parent then child inserted - appendChild", function () {
expect(1);
Expand Down

0 comments on commit b061ba2

Please sign in to comment.