dom-delegate
Advanced tools
Comparing version 0.2.0 to 0.2.1
@@ -463,2 +463,30 @@ /*global buster, assert, refute, Delegate*/ | ||
}, | ||
'Regression test: #root is chainable during setting of root': function() { | ||
var delegate, spy, element; | ||
delegate = new Delegate(); | ||
spy = this.spy(); | ||
delegate.root(document.body).on('click', null, spy); | ||
element = document.body; | ||
element.dispatchEvent(setupHelper.getMouseEvent('click')); | ||
assert.calledOnce(spy); | ||
delegate.off(); | ||
}, | ||
'Regression test: #root is chainable during unsetting of root': function() { | ||
var delegate, spy, element; | ||
delegate = new Delegate(document.body); | ||
spy = this.spy(); | ||
delegate.root().on('click', null, spy); | ||
delegate.root(document.body); | ||
element = document.body; | ||
element.dispatchEvent(setupHelper.getMouseEvent('click')); | ||
assert.calledOnce(spy); | ||
delegate.off(); | ||
}, | ||
'tearDown': function() { | ||
@@ -465,0 +493,0 @@ setupHelper.tearDown(); |
{ | ||
"name": "dom-delegate", | ||
"description": "Create and manage a DOM event delegator.", | ||
"version": "0.2.0", | ||
"version": "0.2.1", | ||
"main": "lib/delegate.js", | ||
@@ -6,0 +6,0 @@ "scripts": [ |
@@ -25,3 +25,3 @@ /*jslint browser:true, node:true*/ | ||
* @constructor | ||
* @param {Node|string} root The root node or a selector string matching the root node | ||
* @param {Node|string} [root] The root node or a selector string matching the root node | ||
*/ | ||
@@ -57,3 +57,4 @@ function Delegate(root) { | ||
* | ||
* @param {Node} root The root node or a selector string matching the root node | ||
* @param {Node|string} [root] The root node or a selector string matching the root node | ||
* @returns {Delegate} This method is chainable | ||
*/ | ||
@@ -84,3 +85,3 @@ Delegate.prototype.root = function(root) { | ||
} | ||
return; | ||
return this; | ||
} | ||
@@ -102,2 +103,4 @@ | ||
} | ||
return this; | ||
}; | ||
@@ -133,3 +136,3 @@ | ||
* @param {string} eventType Listen for these events (in a space-separated list) | ||
* @param {string} selector Only handle events on elements matching this selector | ||
* @param {string|undefined} selector Only handle events on elements matching this selector, if undefined match root element | ||
* @param {function()} handler Handler function - event data passed here will be in event.data | ||
@@ -213,3 +216,3 @@ * @param {Object} [eventData] Data to pass in event.data | ||
* | ||
* @param {string} eventType Remove handlers for events matching this type, considering the other parameters | ||
* @param {string} [eventType] Remove handlers for events matching this type, considering the other parameters | ||
* @param {string} [selector] If this parameter is omitted, only handlers which match the other two will be removed | ||
@@ -424,10 +427,10 @@ * @param {function()} [handler] If this parameter is omitted, only handlers which match the previous two will be removed | ||
if (typeof module === "object") { | ||
module.exports = function(root) { | ||
module.exports = function(root) { | ||
return new Delegate(root); | ||
}; | ||
module.exports.Delegate = Delegate; | ||
}; | ||
module.exports.Delegate = Delegate; | ||
} else if (typeof define === "function" && define.amd) { | ||
define(function() { | ||
define(function() { | ||
return Delegate; | ||
}); | ||
}); | ||
} else { | ||
@@ -434,0 +437,0 @@ window.Delegate = Delegate; |
{ | ||
"name": "dom-delegate", | ||
"version": "0.2.0", | ||
"version": "0.2.1", | ||
"author": "FT Labs <enquiries@labs.ft.com> (http://labs.ft.com/)", | ||
@@ -5,0 +5,0 @@ "description": "Create and manage a DOM event delegator.", |
32871
769