question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Error parsing stylesheets where media query contains classname that contains the string 'container-'

See original GitHub issue

Given the following stylesheet:

@media (max-width: 500px) {
    .container {

    }
    .container_foobar {

    }
}

This gets parsed fine, without error, but the following cases

@media (max-width: 500px) {
    .container- {

    }
    .container-foobar {

    }
}

Causes the following error
chrome_GzAqzOeIvz

As you can see, this only happens if the stylesheet contains a class name that contains the string container-, within a media query

It seems to be trying to emulate a container query for the class container-* by selecting @media (max-width: 500px) { which is not a valid dom selector. It does not fail if the class exists outside of a media query, nor does it fail if the hyphen is absent in the class name.

A point of clarification, I don’t want any emulation of container queries on the above styles There seems to be a conflict with the above styles where the polyfill thinks it needs to find an element to emulate cq.

Tested in Chrome 96.0.4664.45 (Official Build) (64-bit)

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Reactions:3
  • Comments:8

github_iconTop GitHub Comments

6reactions
surmacommented, Dec 2, 2021

Yeah you are right, a string match matches here that technically shouldn’t. I’ll have a think on how to solve this.

2reactions
devknollcommented, Aug 16, 2022

This is fixed in the newest version (currently in alpha). If you have any further issues, please feel free to open a new issue.

Thank you!

Read more comments on GitHub >

github_iconTop Results From Across the Web

Media queries in MUI components - reactjs - Stack Overflow
Returns media query: A media query string ready to be used with JSS. Examples const styles = theme => ({ root: { backgroundColor:...
Read more >
CSS Container Queries - CSS: Cascading Style Sheets | MDN
A media query based on the viewport's width, which is the full width of the ... If the container has less space in...
Read more >
Media Queries for Standard Devices - CSS-Tricks
This page lists a ton of different devices and media queries that would specifically target that device. That's probably not generally a ...
Read more >
CSS Object Model (CSSOM) - W3C
Abstract. CSSOM defines APIs (including generic parsing and serialization rules) for Media Queries, Selectors, and of course CSS itself.
Read more >
Sass: @extend
But this can create cluttered HTML, it's prone to errors from forgetting to include both classes, and it can bring non-semantic style concerns...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found