Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Gutenberg Block: TypeError: Failed to execute 'getComputedStyle' on 'Window': parameter 1 is not of type 'Element'. #427

Open
hsntareq opened this issue Jun 18, 2024 · 1 comment

Comments

@hsntareq
Copy link

hsntareq commented Jun 18, 2024

Initializing this inside Gutenberg Blocks of WordPress is causing this problem. Anyone have solution for this type of error?
image

@collins-lagat
Copy link

The problem actually isn't getComputeStyle but this line:

: elements instanceof HTMLElement

The container property on the slider is actully null:
slider.container = elem(container)

Checkout this thread on gutenberg WordPress/gutenberg#53867

So according to this reply (WordPress/gutenberg#53867 (comment)), you need to check the context of the element to see if it's an iframe or the main window.

A possible fix is this:

elements instanceof elements.ownerDocument.defaultView.HTMLElement

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants