Skip to content

Commit

Permalink
extract context binding from loop, apply when added (#84)
Browse files Browse the repository at this point in the history
* extract context binding from loop, apply when added

* pass function as first param to mutate

* corrected to match other test cases
  • Loading branch information
dhenson02 authored and wilsonpage committed Jun 6, 2016
1 parent bbdc191 commit b0262dd
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
6 changes: 3 additions & 3 deletions fastdom.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ FastDom.prototype = {
*/
measure: function(fn, ctx) {
debug('measure');
var task = { fn: fn, ctx: ctx };
var task = !ctx ? fn : fn.bind(ctx);
this.reads.push(task);
scheduleFlush(this);
return task;
Expand All @@ -72,7 +72,7 @@ FastDom.prototype = {
*/
mutate: function(fn, ctx) {
debug('mutate');
var task = { fn: fn, ctx: ctx };
var task = !ctx ? fn : fn.bind(ctx);
this.writes.push(task);
scheduleFlush(this);
return task;
Expand Down Expand Up @@ -203,7 +203,7 @@ function flush(fastdom) {
*/
function runTasks(tasks) {
debug('run tasks');
var task; while (task = tasks.shift()) task.fn.call(task.ctx);
var task; while (task = tasks.shift()) task();
}

/**
Expand Down
2 changes: 1 addition & 1 deletion test/fastdom-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -340,7 +340,7 @@ suite('fastdom', function() {

test('it removes reference to the job if cleared', function(done) {
var write = sinon.spy();
var id = fastdom.mutate(2, write);
var id = fastdom.mutate(write);

fastdom.clear(id);

Expand Down

0 comments on commit b0262dd

Please sign in to comment.