got it. cool.


On Wed, Feb 26, 2014 at 12:50 PM, Michael Layzell
<notifications@github.com>wrote:

> In destroyer.js:
>
> >    };
> >
> > -  window.start_destroying = function start_destroying() {
> > -    document.querySelector('body').appendChild(mask);
> > -    listeners.push(document.addEventListener('mouseover', mouseover));
> > -    listeners.push(document.addEventListener('click', destroy));
> > -    listeners.push(document.addEventListener('keydown', function(event) {
> > -      if (event.keyCode === 27) {
> > -        escape();
> > -      }
> > -    }));
> > +  var start_destroying = function start_destroying() {
> > +    document.body.appendChild(mask);
> > +    document.addEventListener('mouseover', mouseover);
> > +    document.addEventListener('click', destroy);
> > +    document.addEventListener('keydown', keydown);
>
> That would not work, as keydown would be defined local to the
> start_destroying function, and wouldn't be accessible from the
> stop_destroying function. It also isn't very explicit.
>
> --
> Reply to this email directly or view it on GitHub<https://github.com/uniphil/dom-destroyer/pull/1/files#r10090270>
> .
>