[FIX] #39 - events on top level

Events triggered on top level elements (such as window or document)
lead to a HierarchyRequestError due to a fix in IE browsers
where dispatchEvent does not fire if an element is not in the DOM.

The current test is simply to check for the existence of parentNode
However, this means top level elements get added to itself, causing
the error.

The proposed fix simply tests for top level elements in the test.
This commit is contained in:
darylteo
2016-01-04 22:16:45 +11:00
parent aaa2631eb7
commit 1d292a1a6e

View File

@@ -16,7 +16,7 @@ module.exports = function(els, events, opts) {
forEachEls(els, function(el) {
var domFix = false
if (!el.parentNode) {
if (!el.parentNode && el !== document && el !== window) {
// THANKS YOU IE (9/10//11 concerned)
// dispatchEvent doesn't work if element is not in the dom
domFix = true