diff options
author | Wilson Page <wilsonpage@me.com> | 2016-05-04 10:23:31 +0100 |
---|---|---|
committer | Wilson Page <wilsonpage@me.com> | 2016-05-04 11:03:03 +0100 |
commit | 80d8c2e48d9d12c27d673cc7198b4030f5c32804 (patch) | |
tree | c14e2c038d3b75f8c9e0951ee90064d63f133726 | |
parent | 8d9e20f5354c18c280bd0d19031fff10bf19f5d3 (diff) | |
download | fastdom-80d8c2e48d9d12c27d673cc7198b4030f5c32804.zip fastdom-80d8c2e48d9d12c27d673cc7198b4030f5c32804.tar.gz fastdom-80d8c2e48d9d12c27d673cc7198b4030f5c32804.tar.bz2 |
Fixed incorrect context in fastdom-promised (closes #81)origin/81-fastdom-promised-ctx
-rw-r--r-- | .travis.yml | 3 | ||||
-rw-r--r-- | extensions/fastdom-promised.js | 2 | ||||
-rw-r--r-- | test/fastdom-promised-test.js | 10 |
3 files changed, 14 insertions, 1 deletions
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); + }); + }); }); |