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

fix(postcss-fix-rules): prevent merging of :host(tag) and tag #731

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion CONTRIBUTORS.md
Expand Up @@ -13,7 +13,7 @@ Thanks goes to these wonderful people ([emoji key](https://github.com/kentcdodds
| [<img src="https://avatars.githubusercontent.com/u/5038030?v=3" width="100px;"/><br /><sub><b>Charlike Mike Reagent</b></sub>](http://www.tunnckocore.tk)<br />[💻](https://github.com/cssnano/cssnano/commits?author=tunnckoCore "Code") [⚠️](https://github.com/cssnano/cssnano/commits?author=tunnckoCore "Tests") | [<img src="https://avatars.githubusercontent.com/u/815848?v=3" width="100px;"/><br /><sub><b>Vyacheslav Shebanov</b></sub>](https://github.com/Termina1)<br />[📖](https://github.com/cssnano/cssnano/commits?author=Termina1 "Documentation") | [<img src="https://avatars.githubusercontent.com/u/192323?v=3" width="100px;"/><br /><sub><b>Marek ‘saji’ Augustynowicz</b></sub>](http://twitter.com/saji_)<br />[💻](https://github.com/cssnano/cssnano/commits?author=marek-saji "Code") [⚠️](https://github.com/cssnano/cssnano/commits?author=marek-saji "Tests") | [<img src="https://avatars.githubusercontent.com/u/552316?v=3" width="100px;"/><br /><sub><b>Jonny Gerig Meyer</b></sub>](www.oddbird.net)<br />[💻](https://github.com/cssnano/cssnano/commits?author=jgerigmeyer "Code") [⚠️](https://github.com/cssnano/cssnano/commits?author=jgerigmeyer "Tests") | [<img src="https://avatars.githubusercontent.com/u/237182?v=3" width="100px;"/><br /><sub><b>Fredrik Nicol</b></sub>](https://github.com/faddee)<br />[💻](https://github.com/cssnano/cssnano/commits?author=faddee "Code") [⚠️](https://github.com/cssnano/cssnano/commits?author=faddee "Tests") | [<img src="https://avatars.githubusercontent.com/u/785166?v=3" width="100px;"/><br /><sub><b>Vlad Magdalin</b></sub>](www.webflow.com)<br />[📖](https://github.com/cssnano/cssnano/commits?author=callmevlad "Documentation") | [<img src="https://avatars.githubusercontent.com/u/1198848?v=3" width="100px;"/><br /><sub><b>Dmitry Semigradsky</b></sub>](http://brainstorage.me/semigradsky)<br />[📖](https://github.com/cssnano/cssnano/commits?author=Semigradsky "Documentation") |
| [<img src="https://avatars.githubusercontent.com/u/5701149?v=3" width="100px;"/><br /><sub><b>Selwyn</b></sub>](https://selwyn.cc/)<br />[💻](https://github.com/cssnano/cssnano/commits?author=Siilwyn "Code") [⚠️](https://github.com/cssnano/cssnano/commits?author=Siilwyn "Tests") | [<img src="https://avatars.githubusercontent.com/u/279498?v=3" width="100px;"/><br /><sub><b>Matt Basta</b></sub>](http://mattbasta.com)<br />[💻](https://github.com/cssnano/cssnano/commits?author=mattbasta "Code") | [<img src="https://avatars.githubusercontent.com/u/2559808?v=3" width="100px;"/><br /><sub><b>James Kolce</b></sub>](https://www.jameskolce.com)<br />[📖](https://github.com/cssnano/cssnano/commits?author=jameskolce "Documentation") | [<img src="https://avatars.githubusercontent.com/u/1391716?v=3" width="100px;"/><br /><sub><b>Matthew</b></sub>](http://mattkemp.info/)<br />[💻](https://github.com/cssnano/cssnano/commits?author=techmatt101 "Code") [⚠️](https://github.com/cssnano/cssnano/commits?author=techmatt101 "Tests") | [<img src="https://avatars.githubusercontent.com/u/170197?v=3" width="100px;"/><br /><sub><b>Steven Vachon</b></sub>](https://svachon.com)<br />[📖](https://github.com/cssnano/cssnano/commits?author=stevenvachon "Documentation") | [<img src="https://avatars.githubusercontent.com/u/157534?v=3" width="100px;"/><br /><sub><b>Maxime Thirouin</b></sub>](https://moox.io/)<br />[💻](https://github.com/cssnano/cssnano/commits?author=MoOx "Code") [⚠️](https://github.com/cssnano/cssnano/commits?author=MoOx "Tests") | [<img src="https://avatars.githubusercontent.com/u/170270?v=3" width="100px;"/><br /><sub><b>Sindre Sorhus</b></sub>](https://sindresorhus.com)<br />[📖](https://github.com/cssnano/cssnano/commits?author=sindresorhus "Documentation") [🔧](#tool-sindresorhus "Tools") |
| [<img src="https://avatars.githubusercontent.com/u/2142817?v=3" width="100px;"/><br /><sub><b>Simon Lydell</b></sub>](https://github.com/lydell)<br />[📖](https://github.com/cssnano/cssnano/commits?author=lydell "Documentation") | [<img src="https://avatars0.githubusercontent.com/u/1839?v=3" width="100px;"/><br /><sub><b>Chris Eppstein</b></sub>](http://chriseppstein.github.com)<br />[💻](https://github.com/cssnano/cssnano/commits?author=chriseppstein "Code") [⚠️](https://github.com/cssnano/cssnano/commits?author=chriseppstein "Tests") | [<img src="https://avatars2.githubusercontent.com/u/2511547?v=4" width="100px;"/><br /><sub><b>darthmaim</b></sub>](https://gw2treasures.com/)<br />[💻](https://github.com/cssnano/cssnano/commits?author=darthmaim "Code") | [<img src="https://avatars0.githubusercontent.com/u/848515?v=4" width="100px;"/><br /><sub><b>pigcan</b></sub>](https://github.com/pigcan)<br />[💻](https://github.com/cssnano/cssnano/commits?author=pigcan "Code") [⚠️](https://github.com/cssnano/cssnano/commits?author=pigcan "Tests") | [<img src="https://avatars3.githubusercontent.com/u/4567934?v=4" width="100px;"/><br /><sub><b>Evilebot Tnawi</b></sub>](https://github.com/evilebottnawi)<br />[💻](https://github.com/cssnano/cssnano/commits?author=evilebottnawi "Code") [📖](https://github.com/cssnano/cssnano/commits?author=evilebottnawi "Documentation") [⚠️](https://github.com/cssnano/cssnano/commits?author=evilebottnawi "Tests") | [<img src="https://avatars3.githubusercontent.com/u/10083505?v=4" width="100px;"/><br /><sub><b>Grachev Evgeniy</b></sub>](https://twitter.com/_evless)<br />[💻](https://github.com/cssnano/cssnano/commits?author=evless "Code") | [<img src="https://avatars3.githubusercontent.com/u/26381967?v=4" width="100px;"/><br /><sub><b>Anton Tuzhik</b></sub>](https://github.com/An-Tu)<br />[💻](https://github.com/cssnano/cssnano/commits?author=An-Tu "Code") [⚠️](https://github.com/cssnano/cssnano/commits?author=An-Tu "Tests") |
| [<img src="https://avatars0.githubusercontent.com/u/4847190?v=4" width="100px;"/><br /><sub><b>Ben McKernan</b></sub>](https://github.com/ben-mckernan)<br />[💻](https://github.com/cssnano/cssnano/commits?author=ben-mckernan "Code") [⚠️](https://github.com/cssnano/cssnano/commits?author=ben-mckernan "Tests") | [<img src="https://avatars0.githubusercontent.com/u/122028?v=4" width="100px;"/><br /><sub><b>Ian Walter</b></sub>](https://iankwalter.com)<br />[💻](https://github.com/cssnano/cssnano/commits?author=ianwalter "Code") |
| [<img src="https://avatars0.githubusercontent.com/u/4847190?v=4" width="100px;"/><br /><sub><b>Ben McKernan</b></sub>](https://github.com/ben-mckernan)<br />[💻](https://github.com/cssnano/cssnano/commits?author=ben-mckernan "Code") [⚠️](https://github.com/cssnano/cssnano/commits?author=ben-mckernan "Tests") | [<img src="https://avatars0.githubusercontent.com/u/122028?v=4" width="100px;"/><br /><sub><b>Ian Walter</b></sub>](https://iankwalter.com)<br />[💻](https://github.com/cssnano/cssnano/commits?author=ianwalter "Code") | [<img src="https://avatars1.githubusercontent.com/u/5821279?s=460&v=4" width="100px;"/><br /><sub><b>MapTo0</b></sub>](https://github.com/MapTo0)<br />[💻](https://github.com/cssnano/cssnano/commits?author=MapTo0 "Code") [⚠️](https://github.com/cssnano/cssnano/commits?author=MapTo0 "Tests")
<!-- ALL-CONTRIBUTORS-LIST:END -->

This project follows the [all-contributors](https://github.com/kentcdodds/all-contributors) specification. Contributions of any kind welcome!
7 changes: 7 additions & 0 deletions packages/postcss-merge-rules/src/__tests__/index.js
Expand Up @@ -597,6 +597,13 @@ test(
'.a,.b{display: flex;ALL: initial;border-radius: 2px;color: blue;}.a{margin: 10px 20px;font-size: 10px;}.b{margin: 10px 30px;font-size: 20px;}'
);

test(
'should not merge :host(tagname) with tagname',
processCSS,
':host(tag){display:block}tag{display:block}',
':host(tag){display:block}tag{display:block}',
);

test(
'should merge multiple media queries',
processCSS,
Expand Down
5 changes: 5 additions & 0 deletions packages/postcss-merge-rules/src/index.js
Expand Up @@ -89,6 +89,11 @@ function canMerge (ruleA, ruleB, browsers, compatibilityCache) {
const b = ruleB.selectors;

const selectors = a.concat(b);
const hasHost = selectors.some(selector => selector.includes(":host"));

if (hasHost) {
return false;
}

if (!ensureCompatibility(selectors, browsers, compatibilityCache)) {
return false;
Expand Down