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

TypeError: window.getComputedStyle(...) is null #222

Closed JuusoPalander closed 6 years ago

JuusoPalander commented 6 years ago

Versions

css-element-queries version: 1.0.2 Browser: Firefox 59.0.1 (64-bit) OS: MacOS High Sierra 10.13.3

Issue - ResizeSensor.js:150

var position = window.getComputedStyle(element).getPropertyValue('position');

Here window.getComputedStyle(element) can return null at least on Firefox, and then the subsequent call to .getPropertyValue('position') will throw an error.

Fix

var computedStyle = window.getComputedStyle(element);
var position = computedStyle ? computedStyle.getPropertyValue('position') : null;

Related Firefox bug report

https://bugzilla.mozilla.org/show_bug.cgi?id=548397

marcj commented 6 years ago

Can you provide a pull request please?

JuusoPalander commented 6 years ago

Don't have rights to open it directly. Do you want me to fork the repo and do it that way?