Jsdom: window.requestAnimationFrame is not defined

Created on 29 Aug 2017  路  4Comments  路  Source: jsdom/jsdom

Basic info:

  • Node.js version: v8.0.0
  • jsdom version: 11.2.0

Using jsdom with jsdom-global to test a program that uses requestAnimationFrame. On first test I got

requestAnimationFrame is not defined

Then I added the window namespace and still got that it was not defined. Is there no implementation for it on jsdom and is there a workaround?

feature

Most helpful comment

Yes I think faking it with setTimeout would be great just to make code with it work. I bet no one would really ever expect it to have the original rAF behavior

All 4 comments

Indeed this is not yet implemented in jsdom. You can always add a shim to window, potentially before any parsing: https://github.com/tmpvar/jsdom#intervening-before-parsing

I wonder if we should implement this, with just a 1/60 of a second timer. Or is that too misleading, since jsdom does not paint the screen, ever?

Yes I think faking it with setTimeout would be great just to make code with it work. I bet no one would really ever expect it to have the original rAF behavior

Should also cancelAnimationFrame be made?

@asturur I think it'd be great to have cancelAnimationFrame. I think a clearTimeout should simulate that behavior.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

eszthoff picture eszthoff  路  3Comments

amfio picture amfio  路  3Comments

drewish picture drewish  路  4Comments

lehni picture lehni  路  4Comments

jhegedus42 picture jhegedus42  路  4Comments