Only try to attach events to things that might emit them

This commit is contained in:
Tony Garnock-Jones 2016-05-12 14:46:39 -04:00
parent c6cfa2fe87
commit fb89954158
1 changed files with 10 additions and 8 deletions

View File

@ -264,6 +264,7 @@ UIFragment.prototype.updateEventListeners = function (c, install) {
self.currentAnchorNodes.forEach(function (anchorNode) {
var uiNode = findInsertionPoint(anchorNode, self.fragmentId);
while (uiNode && getBrand(uiNode, self.fragmentId)) {
if ('querySelectorAll' in uiNode) {
var nodes = uiNode.querySelectorAll(c.selector);
for (var i = 0; i < nodes.length; i++) {
var n = nodes[i];
@ -274,6 +275,7 @@ UIFragment.prototype.updateEventListeners = function (c, install) {
n.removeEventListener(cleanEventType(c.eventType), handlerClosure);
}
}
}
uiNode = uiNode.nextSibling;
}
});