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.

Comments

dahousecat created an issue. See original summary.

dahousecat’s picture

gausarts’s picture

Status: Active » Needs work

Thank you.

Mind providing detailed repro steps?
I couldn't reproduce it with tons of samples, but happy to see the underlying cause.

The scope._raf is 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._raf is undefined as your error said, then scope._queue should 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...

gausarts’s picture

Category: Bug report » Support request
Status: Needs work » Fixed

Assumed calling this internal method externally without expected parameters which is not supported, anyway.

However added the proposed check for potential external usages.

Thank you.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.