Skip to content
This repository was archived by the owner on Dec 21, 2019. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions delegation.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ var $ = require("./events")

$.implement({

delegate: function(event, selector, handle){
delegate: function(event, selector, handle, useCapture){

return this.forEach(function(node){

Expand All @@ -34,13 +34,13 @@ $.implement({

map.set(handle, action)

self.on(event, action)
self.on(event, action, useCapture)

})

},

undelegate: function(event, selector, handle){
undelegate: function(event, selector, handle, useCapture){

return this.forEach(function(node){

Expand All @@ -51,7 +51,7 @@ $.implement({
var action = map.get(handle)

if (action){
self.off(event, action)
self.off(event, action, useCapture)
map.remove(action)

// if there are no more handles in a given selector, delete it
Expand Down
6 changes: 4 additions & 2 deletions doc/elements.md
Original file line number Diff line number Diff line change
Expand Up @@ -703,7 +703,7 @@ instance.
### syntax

```js
myElement.delegate(type, selector, fn)
myElement.delegate(type, selector, fn[, useCapture])
```

### parameters
Expand All @@ -712,6 +712,7 @@ myElement.delegate(type, selector, fn)
2. selector - (*string*) A CSS Selector the element the event is fired on should
match (see [matches](#method-matches))
3. fn - (*function*) The function to execute.
4. useCapture - (*boolean*, optional) Whether to use initiate capture

### sample

Expand Down Expand Up @@ -740,7 +741,7 @@ Removes a delegation event listener from an element. Opposite operation of
### syntax

```js
myElement.undelegate(type, selector, fn)
myElement.undelegate(type, selector, fn[, useCapture])
```

### parameters
Expand All @@ -749,6 +750,7 @@ myElement.undelegate(type, selector, fn)
2. selector - (*string*) A CSS Selector the element the event is fired on should
match (see [matches](#method-matches)).
3. fn - (*function*) The function to remove.
4. useCapture - (*boolean*, optional) If the event was registered as a capturing listener or not

### sample

Expand Down