cujojs / when

A solid, fast Promises/A+ and when() implementation, plus other async goodies.
Other
3.44k stars 396 forks source link

Use alternating text node data to avoid MutationObserver polyfill issues #380

Closed briancavalier closed 9 years ago

briancavalier commented 9 years ago

HT tildeio/rsvp.js#171

Apparently, MO polyfills might not trigger when setting an attribute to the same value. This change uses a bit flip to alternate between 0 and 1.

stefanpenner commented 9 years ago

:+1:

marcog83 commented 9 years ago

Hi, I was wondering why MutationObserver has been used to get nextTick. I think for performance in browser enviroment over setTimeout. If so, why not using window.requestAnimationFrame?

briancavalier commented 9 years ago

Hi @marcog83. MutationObserver, when available, is the fastest microtick approach in browsers (faster than requestAnimationFrame).

marcog83 commented 9 years ago

+1000, this kind of knowledge let you be the fastest in terms of performance :)