GithubHelp home page GithubHelp logo

delegate.js's People

Contributors

necolas avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

delegate.js's Issues

Replace _getDelegateTarget with closest

Could we simplify this lib by relying on your closest implementation? It seems the whole of this function can be replaced with a call to closest?

So, this line could be replaced as so:

if (e.delegateTarget = closest(e.target, selector, elem)) {

Aside: I intended to submit PR for this. Couldn't get npm to install as-is (needed to update Karma), and then I couldn't get tests to run

Support `off(type [, selector], callback)`

This change would involve creating a registry to keep track of the element-delegate-callback relationship. It would avoid a callback for a given event type being unbound for all delegators, rather than just the delegator you're interested in.

Doesn't support EventListener interface

An object that implements EventListener interface (https://developer.mozilla.org/en-US/docs/Web/API/EventListener) has a handleEvent method. e.g.:

var obj = {
  log : function(e) {
    console.log("event", e.type, "happened on", e.target);
  },
  handleEvent : function(e) { 
     this.log(e); 
  }
};

Notice that the this value in handleEvent is bound to the object itself. As obj implements the EventListener interface, it can be registered directly as an event listener:

document.addEventListener("click", obj, false);

It would be great if the EventListener interface was respected by delegate.js and worked as one would expect:

delegate(body).on("click", ".some-selector", obj);

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.