Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

CSS class names with BEM modifiers not processed correctly in custom-style by Polymer when inside a media query #2639

Closed
baseten opened this issue Oct 28, 2015 · 4 comments
Labels

Comments

@baseten
Copy link

baseten commented Oct 28, 2015

As a simple test case the following CSS inside shared-styles.css is imported as a custom-style:

.foo {
  width: 100px;
  height: 100px;
  background: #0f0;
}

@media screen and (min-width: 48rem) {
  .foo {
    background: #f00; 
  } 
}

.foo--bar {
  background: #00f;
}

@media screen and (min-width: 48rem) {
  .foo--bar {
    background: #000; 
  } 
}

After this is processed by Polymer (using version 1.2.0) it is output in the head like so:

.foo:not([style-scope]):not(.style-scope) {
  width: 100px;
  height: 100px;
  background: #0f0;
}

@media screen and (min-width: 48rem) {
  .foo:not([style-scope]):not(.style-scope) {
    background: #f00;
  }
}

.foo--bar:not([style-scope]):not(.style-scope) {
  background: #00f;
}

@media screen and (min-width: 48rem) {
  .foo--bar {
    background: #000; 
  }
}

Notice the :not([style-scope]):not(.style-scope) part is missing from .foo--bar within the media query, which means the rule with never be applied as it's specificity is too low to override the rule outside the media query.

@ebidel ebidel added the css label Oct 28, 2015
@nazar-pc
Copy link
Contributor

@baseten, can you clarify with more concrete example how do you import this style? What are files and how are they imported?
Tried various combinations, but can't reproduce with 1.1.5, 1.2.0 and git master code.

@baseten
Copy link
Author

baseten commented Oct 29, 2015

@nazar-pc Repo with minimal test case is here:

https://github.com/baseten/polymer-bem-test

@nazar-pc
Copy link
Contributor

nazar-pc commented Nov 1, 2015

@baseten, fix for this issue is available in PR #2663
@ebidel, would you mind to review it?

@dfreedm dfreedm closed this as completed in 35c89f1 Nov 4, 2015
@baseten
Copy link
Author

baseten commented Nov 5, 2015

@nazar-pc, only just had a chance to test this out. Working great, thanks!

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

No branches or pull requests

3 participants