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

Shim CSS Mixins in terms of CSS Custom Properties #3587

Merged
merged 80 commits into from
Jun 7, 2016

Conversation

dfreedm
Copy link
Member

@dfreedm dfreedm commented Apr 15, 2016

  • Use native css custom properties if supported
    • Rewrite polymer's slightly non-standard syntax to spec
  • Rewrite @apply to N custom properties

If native css custom properties supported, all style work will happen at registration time (+/- shadydom shimming).

Use of updateProperties to modify or create mixins is not supported.

Fixes #3503

dfreedm and others added 30 commits April 14, 2016 15:04
make `getComputedStyleValue` work with native custom properties.
```css
--foo: {
  color: red;
  border: 2px solid black;
}
@apply --foo;
```
becomes
```css
--foo-color: red;
--foo-border: 2px solid black;
color: var(--foo-color);
border: var(--foo-border);
```
move apply-shim to lib
Fix some tests
* fix custom-style test's late registrations.
No more global for defaults
No need to process keyframe rules
Fix up shim var syntax `var(--a, --b)` to `var(--a, var(--b))`
Disable native variables in Safari 9.1 until https://bugs.webkit.org/show_bug.cgi?id=155782 is fixed
Test new `@apply --foo` syntax
Test aliasing mixins with var
Test fixing bad var syntax `var(--a, --b)` -> `var(--a, var(--b))`
Clean up dependencies in apply-shim
Remove lazyRegister hack
Enabled only if support is detected and `lazyRegister` setting is used.

Override with `Polymer = {useNativeCSSProperties: true}` before
polymer is loaded.
Steven Orvell and others added 7 commits May 31, 2016 10:23
- Copy css-build status to cloned style in main document
- Move css-build status out of ast
  - Instead forward a reference to the style in the ast walker callback
More easy to see that no work happens if using a targeted css build with
native custom properties
var combinedProps = mixinValues;
if (oldProperties) {
combinedProps = Polymer.Base.mixin(oldProperties, mixinValues);
} else {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is the else here? Don't we always want to update the property map with the list of all properties that have been used for that mixin?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since we are using mixin, the reference in the map is always the same and we don't need to set again.

dfreedm and others added 3 commits June 3, 2016 10:55
Add test to show that redefining a mixin works as expected
checking for native css custom properties is not needed in the property
shim anymore
@dfreedm
Copy link
Member Author

dfreedm commented Jun 3, 2016

Comments LGTM!

@arthurevans
Copy link

For re-writing the @apply rules, should we consider something less direct than --mixin-prop to avoid possible collisions with other custom properties?

For example, paper-menu has a --paper-menu mixin and a --paper-menu-color property, so:

--paper-menu: { color: red; } 

is going to get rewritten as:

--paper-menu-color: red;

In this case they probably do the same thing, but the collisions could result in unintentional behavior. I'm stretching for an example here, but I can just about imagine a developer using --my-app-background-color (for a default background) and --my-app-background: { color: ... } (for the text color on a background panel).

Anyway, it seems like we should either a) document this potential funkiness, or b) use a less common character to combine the mixin and prop.

@dfreedm
Copy link
Member Author

dfreedm commented Jun 3, 2016

@arthurevans That's a reasonable point. How about '$' or '~' as a separator?

Steven Orvell and others added 2 commits June 3, 2016 16:50
@dfreedm
Copy link
Member Author

dfreedm commented Jun 3, 2016

@arthurevans Went with _-_, so it will be super obvious. separator is also exposed as Polymer.ApplyShim._separator

@arthurevans
Copy link

👍

@sorvell
Copy link
Contributor

sorvell commented Jun 6, 2016

LGTM, can merge when ready...

@dfreedm dfreedm merged commit 6c0acef into master Jun 7, 2016
@dfreedm dfreedm deleted the mixins-as-custom-properties branch June 7, 2016 19:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants