Skip to content
This repository has been archived by the owner on Jun 21, 2023. It is now read-only.

Commit

Permalink
try to ignore events on child nodes which have been retained
Browse files Browse the repository at this point in the history
  • Loading branch information
gr0uch committed Apr 20, 2017
1 parent b5390dc commit c02f56e
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion lib/helpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,12 @@ function makeEventListener (fn, path) {
}


function ignoreEvent (event) {
event.stopPropagation()
event.preventDefault()
}


function bindEvents (events, useCapture) {
var listeners = {}

Expand All @@ -28,11 +34,16 @@ function bindEvents (events, useCapture) {
var key

if (value === null)
for (key in events)
for (key in events) {
// The point of removing event listeners here is not manual memory
// management, but to ensure that after the value has been unset, it
// no longer triggers events.
node.removeEventListener(key, listeners[key], useCapture)

// Add a capturing event listener to make future events effectively
// ignored.
node.addEventListener(key, ignoreEvent, true)
}
else if (previousValue === null)
for (key in events) {
listeners[key] = makeEventListener(events[key], path)
Expand Down

0 comments on commit c02f56e

Please sign in to comment.