Problem/Motivation
I'm getting js error: Uncaught TypeError: i._raf is undefined in blazy.observer.min.js
From looking at old versions of the module with unminified js I know i is scope, so scope._raf is undefined.
Steps to reproduce
Open a page with blazy, look at the js console.
Proposed resolution
I have no idea what _raf is used for however just checking if it's undefined and if so setting it to an array makes the error go away and as far as I can tell doesn't have any adverse side effects.
| Comment | File | Size | Author |
|---|---|---|---|
| #2 | blazy-observer-_raf-undefined-3440431-01.patch | 2.57 KB | dahousecat |
Comments
Comment #2
dahousecat commentedComment #3
gausarts commentedThank you.
Mind providing detailed repro steps?
I couldn't reproduce it with tons of samples, but happy to see the underlying cause.
The
scope._rafis always defined before calling the observer here:https://git.drupalcode.org/project/blazy/-/blob/8.x-2.x/js/src/base/io/b...
Technically if
scope._rafis undefined as your error said, thenscope._queueshould be, too, but you didn't indicate it so?Also you may want to update the non-minified JS here as well:
https://git.drupalcode.org/project/blazy/-/blob/8.x-2.x/js/src/plugin/bl...
Comment #4
gausarts commentedAssumed calling this internal method externally without expected parameters which is not supported, anyway.
However added the proposed check for potential external usages.
Thank you.