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

Upgrade to Stylis 3 #829

Merged
merged 4 commits into from May 27, 2017
Merged

Upgrade to Stylis 3 #829

merged 4 commits into from May 27, 2017

Conversation

kitten
Copy link
Member

@kitten kitten commented May 25, 2017

No description provided.

@kitten
Copy link
Member Author

kitten commented May 25, 2017

@thysultan I'm seeing some weird { ; } artefacts. Most of them disappeared when I switched on the compress option, but not all of them.

@mxstbr-bot
Copy link

mxstbr-bot commented May 25, 2017

Warnings
⚠️ There are library changes, but not tests. That's OK as long as you're refactoring existing code

Generated by 🚫 dangerJS

@kitten
Copy link
Member Author

kitten commented May 25, 2017

@thysultan some duplication in ssr.test:

    -/* sc-component-id:sc-global-2303210225 */
    -body{ background:papayawhip; }
    +/* sc-component-id: sc-global-2358157387 */
    +{ ; }
    +body{ background:papayawhip}
    +body{ background:papayawhip}
    +body{ background:papayawhip}
    +body{ background:papayawhip}

@thysultan
Copy link

thysultan commented May 25, 2017

I'm seeing some weird { ; } artefacts.

This is by design, V3 adds semicolons where omitted to support no-semicolons, so

h1 {
    color:red
} -> h1{
    color:red;
}

some duplication in ssr.test:

This looks like a bug, whats the full input?

@thysultan
Copy link

thysultan commented May 25, 2017

@philpl patched some of theses in 3.0.1, BTW the cascade option should be true(default), false turns of cascading.

Do you know what is passed to stylis in this case

body{ background:papayawhip}
body{ background:papayawhip}
body{ background:papayawhip}

Edit: found the bug

@thysultan
Copy link

thysultan commented May 25, 2017

Managed to patch it...

Where do these empty blocks .sc-a { } come from?

@mxstbr
Copy link
Member

mxstbr commented May 25, 2017

Where do these empty blocks .sc-a { } come from?

Those are on purpose, they are per-component rather than the others, which are per-instance-of-css-fragment 😊

@thysultan
Copy link

thysultan commented May 25, 2017

I was trying to track down where and how they are passed to stylis, since stylis removes empty blocks its a bit odd that they would appear, if they are getting passed through it.

@thysultan
Copy link

Most failed tests now are whitespace related...

Is there a way to have the tests break up on a failed test to mitigate having to view all the failed tests at once.

@kitten
Copy link
Member Author

kitten commented May 25, 2017

Hiya, I'll finish this PR this evening :) yea, you can use jest's file filter with the P key

@kitten
Copy link
Member Author

kitten commented May 27, 2017

@thysultan found another bug... I think:

-  .sc-a{ } .c{ color: blue; } .c > h1{ font-size: 4rem; } .sc-b{ } .d{ color: blue; } .d > h1{ font-size: 4rem; } .d{ color: red; }
+ .sc-a{ } .c{ color: blue; } .c > h1{ font-size: 4rem; } .sc-b{ } .d{ color: blue; color: red; } .d > h1{ font-size: 4rem; }

Source:

    const Parent = styled.div`color: blue;`
    const Child = Parent.extend`color: red;`

It seems to be combining the two color properties across rules here, but I'm unsure whether this changes the behaviour in terms of specificity, due to it being the same, but in a different order? (A bit confused)

Edit: btw that's the last outstanding question/regression/issue/dunno

Edit 2: Ok, correct me afterwards if I'm wrong—tired at this point—but my abysmal knowledge of CSS specificity tells me that this is indeed a correct merge

@geelen
Copy link
Member

geelen commented May 27, 2017

Hmm, is the red in the above expected or what v3 is putting out. Because I think it's more correct.

@geelen
Copy link
Member

geelen commented May 27, 2017

Depends on what exactly is in that test case. Could you post a link to the source?

@kitten
Copy link
Member Author

kitten commented May 27, 2017

@geelen it's merging the two rules that have the same selectors in the correct order. So (see Edit2) i think it's correct.

@kitten
Copy link
Member Author

kitten commented May 27, 2017

@geelen the updated test case is here: 894415e

Wanna review this? :)

@kitten kitten changed the title [WiP] Upgrade to Stylis 3 Upgrade to Stylis 3 May 27, 2017
@thysultan
Copy link

thysultan commented May 27, 2017

It's by design, it now behaves like it would in sass/postcss we where talking about this before here #286. I decided it's better to have parity with scss to avoid unexpected results, i.e nested @mediablock issues.

BTW, is there any reason for this stringifyRules.js#L23-L25

  const cssStr = (selector && prefix) ?
    `${prefix} ${selector} { ${flatCSS} }` : // here
    flatCSS

// and
.replace(/^\s*\/\/.*$/gm, '') // replace JS comments

@kitten
Copy link
Member Author

kitten commented May 27, 2017

@thysultan yea, these lines are for several cases that need to line up with the preprocessing:

On the normal side: https://github.com/styled-components/styled-components/blob/master/src/constructors/keyframes.js#L19

On the preprocessing side we then use it like this: https://github.com/styled-components/styled-components/blob/master/src/no-parser/stringifyRules.js#L13

It's all stuff that will be cleaned up with v3, since the entire preprocessing logic and the way we'll use stylis will change then :) (as discussed prior)

Copy link
Member

@geelen geelen left a comment

Choose a reason for hiding this comment

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

Alright this looks good to me

@kitten kitten merged commit d58c045 into master May 27, 2017
@mxstbr mxstbr deleted the update-stylis-3 branch May 27, 2017 15:25
@kitten kitten mentioned this pull request Jun 2, 2017
@brunolemos
Copy link
Member

brunolemos commented Jun 5, 2017

@philpl don't you get this error? Maybe it's because I'm using react-native-web:

ReferenceError: escade is not defined

thysultan/stylis#30

@kitten
Copy link
Member Author

kitten commented Jun 5, 2017

@brunolemos Oh, I didn't get that error in any test. Weird. Seems to be fixed now and we'll just need to update the yarn lockfile on release

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

Successfully merging this pull request may close these issues.

None yet

6 participants