diff --git a/.travis.yml b/.travis.yml index 8ed9373..e523568 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,3 +1,6 @@ +sudo: required +dist: trusty + language: node_js node_js: diff --git a/extensions/fastdom-promised.js b/extensions/fastdom-promised.js index e002072..1d0868f 100644 --- a/extensions/fastdom-promised.js +++ b/extensions/fastdom-promised.js @@ -60,7 +60,7 @@ function create(promised, type, fn, ctx) { var promise = new Promise(function(resolve, reject) { task = fastdom[type](function() { tasks.delete(promise); - try { resolve(fn()); } + try { resolve(ctx ? fn.call(ctx) : fn()); } catch (e) { reject(e); } }, ctx); }); diff --git a/test/fastdom-promised-test.js b/test/fastdom-promised-test.js index 959800e..f1e95dd 100644 --- a/test/fastdom-promised-test.js +++ b/test/fastdom-promised-test.js @@ -45,4 +45,14 @@ suite('fastdom-promised', function() { done(); }); }); + + test('it calls callback with given context', function() { + var spy = sinon.spy(); + var ctx = {}; + + return fastdom.measure(spy, ctx) + .then(function() { + sinon.assert.calledOn(spy, ctx); + }); + }); });