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

Drop :root limitation using new selector/rules injections ? #30

Closed
MoOx opened this issue Jun 22, 2014 · 4 comments
Closed

Drop :root limitation using new selector/rules injections ? #30

MoOx opened this issue Jun 22, 2014 · 4 comments

Comments

@MoOx
Copy link
Contributor

MoOx commented Jun 22, 2014

Like said here I was that dropping :root limitation should be that hard using selector injection like it has been already said in other issues. This could also fix #17

:root {
  --mainColor: red;
}

a {
  color: var(--mainColor);
  other: rule;
}

p {
  --mainColor: blue;
  border: 1px solid var(--mainColor)
}

I would expect

a {
  color: red;
  other: rule;
}

p {
  border: 1px solid blue;
}

p a {
  color: blue;
}

Not sure about what I'm missing. I know we cant guess dom & so update appropriate result, but we could inject new selectors with rules that make use of var() like in the example above.
Obviously that can represent a huge amount of selectors to add if there is a lot of variable & a lot of usage, but that will do the job "as expected".

I was thinking of an incoming issue with #id selectors related to injection but can't remind it right now it's too early in the morning here.

@necolas
Copy link
Contributor

necolas commented Jun 22, 2014

It's impossible to make it work like native css vars would. Non-:root variables are tied to the DOM tree so you can't know what selectors to create ahead of time.

@necolas necolas closed this as completed Jun 22, 2014
@MoOx
Copy link
Contributor Author

MoOx commented Jun 22, 2014

I know we can't guess the dom, that's why i was mentionning the possibility to inject all possibilities under selectors that are defining non root custom prop. This may sound brutal indeed but I dont understand why this will be not enough.
Could you provide me an example that cant be reproduced with injection please ?

@necolas
Copy link
Contributor

necolas commented Jun 22, 2014

Because there are too many possibilities. What about nested components each with their own local variable overrides? It's not something we can get right outside of the DOM tree. Even if we could, it would be a nightmare to debug this kind of thing.

@tabatkins
Copy link

Agreed. It's theoretically possible to do this, and might even be plausible if you only override a given variable in one place, but the number of rules necessary scales at least as fast as (number of places setting the var)*(number of places using the var). I think it actually goes combinatorial on one of those factors, but I don't want to think it through. ^_^

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

No branches or pull requests

3 participants