marcj / css-element-queries

CSS Element-Queries aka Container Queries. High-speed element dimension/media queries in valid css.
http://marcj.github.io/css-element-queries/
MIT License
4.27k stars 487 forks source link

Failed to execute 'getComputedStyle' on 'Window': param 1 is not of type 'Element'. #219

Closed rejhgadellaa closed 5 years ago

rejhgadellaa commented 6 years ago

Hi there,

I'm trying to use your library but I'm getting an error:

Uncaught TypeError: Failed to execute 'getComputedStyle' on 'Window': parameter 1 is not of type 'Element'. at HTMLBodyElement. (ElementQueries.min.js:421)

This is line 421:

var sensorStyles = window.getComputedStyle(element.resizeSensor, null);

So.. element.resizeSensor is not an element. I just checked and it's actually undefined :(

Any clue what's wrong?

mhlavacek commented 6 years ago

I'm getting the same error.

mhlavacek commented 6 years ago

I was able to at least get a workaround going while the issue gets fixed. Update line 421 in the ElementQueries.js file to be the following...

var sensorStyles = window.getComputedStyle(element.resizeSensor || element, null);

@rejhgadellaa

marcj commented 6 years ago

This issue is coming from the fact that in the newest master version we use ResizeObserver in Chrome where element.resizeSensor is then indeed undefined. See #213 by @movedoa

Please use 1.0.2 instead of the master version.

rejhgadellaa commented 6 years ago

Awesome thanks! 🎈

enventa commented 6 years ago

Hi @marcj

Please use 1.0.2 instead of the master version

I'm afraid using version 1.0.2 doesn't fix this issue. At least, on my installation doesn't work, the problem appears using both, 1.0.2 and master version.

marcj commented 5 years ago

This should be fixed in the latest version. Please try again and give feedback

wrightdaniel2017 commented 2 years ago

still getting issue in 2022!