wilsonpage / fastdom

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

V1 beta microtask #67

Closed wilsonpage closed 8 years ago

wilsonpage commented 8 years ago

Let create a pull-request so we can leave comments etc :)

wilsonpage commented 8 years ago

I'll try to get time to properly test and review this. I don't have much bandwidth right now. Any unit-tests you can add that prove this concept further would be a big help :)

aFarkas commented 8 years ago

Will do this weekend.

aFarkas commented 8 years ago

As you might have seen, I updated the tests. I had some problems to add a lot more tests, because most things about read/write are already tested. I instead made some changes to make the tests more strict.

Beside those small improvements, I added two new tests.

  1. "Should optimally not call a read in rAF": This thing we can only test by starting from a rAF, because in all other situations it might work or don't
  2. "Should call a read always before next frame": This is kind of a brute force test, because if we would test it only once and our implementation code wouldn't enforce what we wan't it would fail only sometimes. By doing this test 3 times nested (and commenting out our line that enforces this) it fails always, if not enforced.
wilsonpage commented 8 years ago

I've landed the v1-beta branch in master, so this can be rebased. I'm still uncertain as to whether this is a safe approach due to uncertainties over when setTimeout(..., 0) runs.