summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--index.js5
-rw-r--r--test/test.clear.js14
2 files changed, 18 insertions, 1 deletions
diff --git a/index.js b/index.js
index 4609a51..e91cc9c 100644
--- a/index.js
+++ b/index.js
@@ -143,7 +143,7 @@
* Clears a scheduled 'read',
* 'write' or 'defer' job.
*
- * @param {Number} id
+ * @param {Number|String} id
* @public
*/
FastDom.prototype.clear = function(id) {
@@ -153,6 +153,9 @@
return this.clearFrame(id);
}
+ // Allow ids to be passed as strings
+ id = Number(id);
+
var job = this.batch.hash[id];
if (!job) return;
diff --git a/test/test.clear.js b/test/test.clear.js
index f0f60b1..1230b16 100644
--- a/test/test.clear.js
+++ b/test/test.clear.js
@@ -93,4 +93,18 @@ suite('clear', function(){
});
});
});
+
+ test('Should accept String ids', function(done) {
+ var fastdom = new FastDom();
+ var read = sinon.spy();
+
+ var id = fastdom.read(read);
+
+ fastdom.clear(id.toString());
+
+ raf(function() {
+ assert(!read.called);
+ done();
+ });
+ });
}); \ No newline at end of file