bitovi/canjs — pull request #758 by andykant (2014-02-28 23:21:49+00:00)
Title: Added delegate/undelegate fallbacks to bind/unbind and fixed broken Zepto/Dojo delegate implementations #754

`can.delegate` and `can.undelegate` (in util/LIBRARY/LIBRARY.js) don't implement fallback binding for objects for non-elements and objects that don't explicitly define delegate/undelegate.

Additionally, the existing Zepto/Dojo delegate methods completely fail in cases where the `selector === ""`.

This pull request fixes these issues by having `can.delegate/undelegate` fallback to their `can.bind/unbind` counterparts in cases where normal object instances don't implement delegate/undelegate. Also included is the addition of `can/util/event` and `can/control/modifier` tests to the tests run with all libraries in `test/*` as well as adding `test/jquery-2.html` to `test/index.html`.

For example in **util/jquery/jquery.js**:
``` javascript
delegate: function(selector, ev , cb){
if(this.delegate) {
this.delegate(selector, ev , cb)
}
else if(isBindableElement(this)) {
$(this).delegate(selector, ev, cb)
} else {
// make it bind-able ...
}
return this;
},
undelegate: function(selector, ev , cb){
if(this.undelegate) {
this.undelegate(selector, ev , cb)
}
else if(isBindableElement(this)) {
$(this).undelegate(selector, ev, cb)
} else {
// make it bind-able ...

}
return this;
},
```

The problem with this is there are portions of the CanJS codebase that call `.delegate` instead of `.bind`. Specifically, modifier functions like in `can/control/modifier`.
``` javascript
steal("can/construct", "can/control", "can/control/modifier", function(Construct, Control) {
Construct("SomeObject", {
bind: can.bind,
unbind: can.unbind,
dispatch: can.dispatch
});

Control('SomeClass', {
init: function() {
this.options.some_object = new SomeObject();
this.on();
},
"{some_object} some_event:debounce(100)": function() {
// THIS NEVER FIRES
}
});

var control = new SomeClass(document.body);
control.options.some_object.dispatch("some_event");
});
```