shadycss icon indicating copy to clipboard operation
shadycss copied to clipboard

custom mixins not converted correctly

Open jaichandra opened this issue 9 years ago • 3 comments

When a mixin is declared at two places, the one at the top takes precedence, but the other declaration is completely ignored. Ideally it should also be included.

Demo:

https://jsbin.com/gohoduf/edit?html,output This example contains a style module and a custom-style to test custom mixin's load order Here’s what I got in the debugger window.

:host([animated]) {
    color: var(--my-mixin_-_color);
}
...
:host {
    --my-mixin_-_background-color: #ff00ff;
    --my-mixin_-_color: initial;
}
...
:host {
    display: block;
}
...
html {
    --my-mixin_-_color: red;
}

I see two issues here:

  1. host([animated]) should include both style properties - color and background-color
  2. --my-mixin_-_color: initial; shouldn't be generated as there are no overrides on color property.

jaichandra avatar Mar 30 '17 18:03 jaichandra

Think this is related to #69

TomK avatar Mar 30 '17 18:03 TomK

Well, here are some updates. I tried simplifying the example to just one mixin definition and it turns out that the style-modules load order made a difference. Here's an updated example and this tries to replicate the same use case that is mentioned in the documentation of apply-shim.js. https://jsbin.com/qekuhow/1/edit?html,output

Here, I can see all css properties correctly included. But there's certainly is a problem with how they are converted. The initial part in the last :host {} definition below looks wrong.

:host {
    color: var(--foo_-_color);
    background: var(--foo_-_background);
    border: var(--foo_-_border);
}
...
:host {
    --foo_-_color: red;
    --foo_-_background: blue;
    --foo_-_border: initial;
}
...
html {
    --foo_-_border: 2px solid red;
}

jaichandra avatar Mar 30 '17 19:03 jaichandra

Ah yeah, this is because style include is prefixed and the apply shim only scans above the usage site to generate properties.

This example works correctly, because the @apply is after the mixin declaration: https://jsbin.com/hukovar/1/edit?html,output

This is probably not very easy to solve.

dfreedm avatar Apr 04 '17 00:04 dfreedm