wilsonpage / fastdom

Eliminates layout thrashing by batching DOM measurement and mutation tasks
6.85k stars 240 forks source link

Context not working with fastdom-promised? #81

Closed Dylan-Chapman closed 8 years ago

Dylan-Chapman commented 8 years ago

I noticed some weird inconsistent behavior between fastdom and fastdom-promised earlier.

var ctx = { test: "test" };

fastdom.measure( function() {
    console.log( this ); // => outputs { test: "test" }
}, ctx );

fastdomPromised.measure( function() {
    console.log( this ); // => outputs the window object
}, ctx );

Is this intended behavior? Is this not a way in which context is supposed to be used?

wilsonpage commented 8 years ago

Ah yes, I think this is a bug. The bug is here

fn should be called like: fn.call(ctx).

Alternatively for a quickfix you can use either:

Dylan-Chapman commented 8 years ago

Yep, you were right! fn.call(ctx) on that line does the trick.

wilsonpage commented 8 years ago

Could you send a PR? :)

On Tue, 3 May 2016 17:22 Dylan Chapman, notifications@github.com wrote:

Yep, you were right! fn.call(ctx) on that line does the trick.

— You are receiving this because you commented.

Reply to this email directly or view it on GitHub https://github.com/wilsonpage/fastdom/issues/81#issuecomment-216583756