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

ResizeSensor bug when getting element position property #207

Closed artemnikotin closed 6 years ago

artemnikotin commented 6 years ago

Seems you have problem (version 1.0.0) on line 147, when trying to get element position, but got position priority

var position = window.getComputedStyle(element).getPropertyPriority('position');
if ('absolute' !== position && 'relative' !== position && 'fixed' !== position) {
    element.style.position = 'relative';
}
marcj commented 6 years ago

What do you mean? "position priority"? What error do you get?

artemnikotin commented 6 years ago

Hi, @marcj In my project, ResizeSensor overwrite 'position' property to "relative", even if I set it via css to "absolute".

getPropertyPriority() method returns the priority of the property, e.g. "important" or empty string, but in described code we are waiting for the property value (we produce comparisons with 'position' values). We can use getPropertyValue() for it. So line 147 could be replaced on:

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

What do you think?

marcj commented 6 years ago

Oh you're right, a stupid typo. Would you like to provide a PR with the fix?

marcj commented 6 years ago

fixed