Skip to content
This repository has been archived by the owner on May 14, 2021. It is now read-only.

feat(selector-guessing): improve guess at selector #281

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

uniqname
Copy link

@uniqname uniqname commented Oct 3, 2019

This is a bit of a selfish PR, but I was thinking we could be just a bit smarter about guessing whether an interpolation is a selector or not. I don't think that & and > aren valid tokens in CSS for anything other than as part of a selector, so we could use those to reduce the need for sc tags. This helps in cases like the following (very common in our code base, don't know how common in others):

const SomeCompnent = styled(MyComponent)`
  & > ${SomeChild},
  & > ${OtherChild} {
    color: blue;
  }
`

SomeChild would not be identified as a selector since it is part of a list of selectors. Commas are valid CSS tokens in lots of scenarios, so looking for that is not really an option, but & and > are only valid as part of a selector (I don't think 馃 ), so it would at least cover those. Thoughts? Am I way off base here?

@coveralls
Copy link

Coverage Status

Coverage remained the same at 100.0% when pulling e8a6bb9 on uniqname:fix/selector-guess into 8a5fab0 on styled-components:master.

@chinesedfan
Copy link
Member

@uniqname Sure. Can you add some test cases for your new work?

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

Successfully merging this pull request may close these issues.

None yet

3 participants