-
Notifications
You must be signed in to change notification settings - Fork 2k
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 for incorrect CSS selectors specificity (fixes at least #2531, #1873 and #2621) #2642
Conversation
Tests are also added (pretty basic, but anyway). |
Added fix for #1873 since it touches similar places, so it would be much easier to merge, tests added for this case as well. .green-2 {
border-top: 2px solid green;
@apply(--x-overriding);
} works in the same way as: .green {
@apply(--x-overriding);
border-top: 2px solid green;
} So, |
@sorvell, it seems you're the one whom I should ask for review here. |
I would love to see order taken into account
Using your example, this allows me to set a default border-top. The @apply may/may not have border styles .green-2 {
border-top: 2px solid green;
@apply(--x-overriding);
} |
|
Is it possible to include a fix for #2621 too? (if this PR doesn't already fix the problem described) Seems they are closely related. |
@JeremybellEU, this PR should fix #2621 already. |
Asked about Now this PR seems to be complete and ready to radically improve experience of Polymer users when dealing with CSS mixins/variables 🚀🚀🚀 @mfrost66, give it a try. P.S. @sorvell, I hope you'll find some time for review in nearest future. Some of my non-merged PRs are waiting from 5th of August till today 😢 |
List of patches applied on top of stable version (one previous patch upstreamed, the rest are still here): * Polymer/polymer#2205 * Polymer/polymer#2247 * Polymer/polymer#2295 * Polymer/polymer#2349 * Polymer/polymer#2419 * Polymer/polymer#2642 * Polymer/polymer#2663 * Polymer/polymer#2664
+1 |
R: @tjsavage for slotting |
This PR is pretty big, so I'm reviewing it last. I'll do the merge conflict work unless it gets too nasty. |
I can rebase it if necessary |
that would be great :) |
3c1097f
to
e3798e1
Compare
Rebased against master |
👍 I can finally stop spamming |
@sorvell for review |
1b7f4f6
to
7dcb47f
Compare
WOW, just simplified it A LOT! |
List of patches applied on top of git version (2 previous patches upstreamed, the rest are still here + 2 new patches added): * Polymer/polymer#2205 * Polymer/polymer#2247 * Polymer/polymer#2295 * Polymer/polymer#2349 * Polymer/polymer#2419 * Polymer/polymer#2642 * Polymer/polymer#2689 * Polymer/polymer#2692 * Polymer/polymer#2694
Thanks for doing this PR. We were considering solving this issue as in the PR, but we're a little concerned about the performance burden of having excess rules in the custom properties css. I'm going to try to dive into this and if the cost looks low, we'll go ahead and merge this. Our longer term plan is to explore integrating custom property css together with the rest of the element css, making updates to custom properties via the CSSOM and using a single stylesheet for all of an element's styles. This is fairly involved and will mean more significantly forking the code for Shadow v. Shady DOM. |
Fix for overriding mixin properties, fixes Polymer#1873 Added awareness from `@apply()` position among other rules so that it is preserved after CSS variables/mixing substitution. `Polymer.StyleUtil.clearStyleRules()` method removed as it is not used anywhere. Some unused variables removed. Typos, unused variables and unnecessary escaping in regexps corrected. Tests added.
7dcb47f
to
fd57784
Compare
Rebased against master to resolve merging conflicts, squashed everything into single commit, since history was not useful. |
List of patches applied on top of git version (no new patches upstreamed since last time:(): * Polymer/polymer#2205 * Polymer/polymer#2247 * Polymer/polymer#2295 * Polymer/polymer#2349 * Polymer/polymer#2419 * Polymer/polymer#2642 * Polymer/polymer#2689 * https://github.com/Polymer/polymer/tree/fix-2692 branch supersedes Polymer/polymer#2692 * Polymer/polymer#2694
#2642 is another specificity issue likely fixed by this. |
I guess it was a typo, #2642 is this PR's id. |
Yes #2731 is the issue |
@ebidel Can you provide a status update? I'm discouraged by the level of changes since the 1.0 release in regards to styling. Not only have you significantly changed the feature set of 1.x with deprecation of /deep/ and css imports, but the proposed solution (mixins,vars) is buggy and of apparent low priority as evidenced by the age of this PR. The level of effort required on our (users) part to stay up with an every-changing API is non-trivial. More so when the features are either buggy or not well thought out.
Your statement above implies that there is more significant change planned for the future. My initial enthusiasm for web components is slowly turned into trepidation. A clear statement on the status of styles and roadmap/timeline for a "final" solution would be greatly appreciated. A timely fix for the current bugs surrounding styles would also be wonderful. A caveat emptor on the polymer home page wouldn't be out of order until the team's able to sort this mess out. |
@mfrost66, if you don't mind you can use often up to date version of Polymer with bunch of extremely useful patches in JS form (not HTML imports form to speed up things in browsers other than Chromium) here: https://github.com/nazar-pc/CleverStyle-CMS/tree/master/includes/js And yes, I'm very sad with pace of PRs merging too, since most of major issues are in fact already fixed for a long time now, just not upstreamed. |
@nazar-pc Thanks, which of the libraries would I need - just the a4.polymer*.js file? I actually tried to apply your patches locally but ran into the sad fact that polymer doesn't build on windows and I was too flabbergasted to keep trying. |
@mfrost66, yes, just that file - it contains Micro, Mini and Standard - full Polymer version that you'd get by including |
@nazar-pc In the example below, "inner content" should be colored red. test.html <!DOCTYPE html>
<html>
<head>
<script charset="utf-8" src="bower_components/webcomponentsjs/webcomponents.js"></script>
<link rel="import" href="bower_components/polymer/polymer.html">
<link rel="import" href="my-modules.html">
</head>
<body>
<my-paragraph>
<my-text>inner content</my-text>
</my-paragraph>
</body>
<script>
</script>
</html> my-modules.html <dom-module id="my-text">
<style>
:host {
display: block;
color:var(--my-text-color,blue);
}
</style>
<template><content></content></template>
<script> Polymer({ is:'my-text'}) </script>
</dom-module>
<dom-module id="my-paragraph">
<style>
:host { --my-text-color:red; }
:host ::content * { --my-text-color:red; } /*tried this too*/
</style>
<template>
<my-text>Outer content</my-text>
<content></content>
</template>
<script> Polymer({ is:'my-paragraph'}) </script>
</dom-module> |
It should not work, you're applying color to |
This change looks fine to me. @nazar-pc can you rebase this PR? |
Hmm, I believe it should in fact work. From polymer styles doc's:
Perhaps its not related to this PR? I'll post it as a new bug. |
@nazar-pc scratch that, I'll rebase it since the conflict is with something I wrote :P |
Merged! Sorry for the delay, the team has been heads down on some performance work, and I'm helping get everything back on track. |
As reported in #2531 (while I expect many other similar might be fixed as well).
I've also fixed 2 existing tests where order of styles was hardcoded (it changed a bit now, but preserves priority even better and no other tests affected).
Tested manually under Shady DOM, Shadow DOM and Shadow DOM polyfill.
More tests specific to these improvements will be added soon (now it is time to sleep:)).