Simplebar: [Bug] Uncaught TypeError: Failed to execute 'getComputedStyle' on 'Window': parameter 1 is not of type 'Element'.

Created on 22 Aug 2020  路  8Comments  路  Source: Grsmto/simplebar

Hello everyone! I am using the library and it is perfect. Everything was working fine until I started seeing these errors in console:

simplebar.min.js:formatted:1911 Uncaught TypeError: Failed to execute 'getComputedStyle' on 'Window': parameter 1 is not of type 'Element'.
    at MutationObserver.e.recalculate (simplebar.min.js:formatted:1911)
    at d (simplebar.min.js:formatted:1512)
    at p (simplebar.min.js:formatted:1517)
    at MutationObserver.m (simplebar.min.js:formatted:1545)

When expanded it can be seen that it happens from calling the jquery .append() to scroll container.
Basically what I have on the page is a container with a bunch of inputs. When the user types the input expands to fit the text until 140px by using hidden span element. I guess that means that every time the user enters a character the scrollbar is trying to recalculate and this problem occurs.

Hoping to solve the problem. Thank you.

Update

I looked through debugger and it seems that the problem occurs because the mutation observer's property .el is undefined.

question

Most helpful comment

Solved by specifying version in cdn url. (if you use cdn to load the module)

<script src="https://unpkg.com/[email protected]/dist/simplebar.min.js"></script>

I think they accidentally point the lastest version to beta release.

All 8 comments

Same problem happens to me

Solved by specifying version in cdn url. (if you use cdn to load the module)

<script src="https://unpkg.com/[email protected]/dist/simplebar.min.js"></script>

I think they accidentally point the lastest version to beta release.

Might a problem with scopes: recalculate() should be bound to the SimpleBar class scope.
Anyway, like @d4n1elchen mentioned, v5 doesn't have this problem.

     ERROR TypeError: Failed to execute 'getComputedStyle' on 'Window': parameter 1 is not of type 'Element'.

This is still and issue in angular-simplebar from the simplebar-core.esm.js:509

Yeah, it just seems like this has been done by mistake in the core file, because I didn't change anything in the code. It happened by itself.

Also checked it in a completely new empty project with a parent scroll object and just random content inside and it was still spitting these errors every time I appended to the parent element.

Hey if you use the simplebar package instead of the angular wrapper the error is no more tho. I guess the way the angular wrapper is made is just not working right now

Released a fix in the latest beta releases.

Uncaught TypeError: Failed to execute 'getComputedStyle' on 'Window': parameter 1 is not of type 'Element'.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

apopelyshev picture apopelyshev  路  7Comments

bennymeg picture bennymeg  路  3Comments

Aleksandr2015 picture Aleksandr2015  路  6Comments

adjourn picture adjourn  路  6Comments

barnu5 picture barnu5  路  5Comments