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

Should :extend(.selector all) flag be !all? #29

Open
matthew-dean opened this issue Jul 5, 2018 · 5 comments
Open

Should :extend(.selector all) flag be !all? #29

matthew-dean opened this issue Jul 5, 2018 · 5 comments

Comments

@matthew-dean
Copy link
Member

matthew-dean commented Jul 5, 2018

I realized I've felt this way for a while but haven't raised it as a specific issue.

I think we should change this...

.foo:extend(.bar all) {}

...to...

.foo:extend(.bar !all) {}  // !all flag

That is, it's long felt odd to me that all looks like a regular selector. I think it should be a flag, like !important. Obviously if we ever got around to implementing deep it would be the same way.

It would be trivial in the parser to make ! optional, and then later update docs to prefer it, but I'm wondering how others feel about it.

@seven-phases-max
Copy link
Member

If it's about opinions I wonder why it's "!". The !important thing the most dreadful and silly CSS feature (with ! meaning "never ever use me, young padavan"), so whatever it goes - the ! as a disambiguation symbol for reserved extend keywords is the worst choice to my taste.

@matthew-dean
Copy link
Member Author

@seven-phases-max

The !important thing the most dreadful and silly CSS feature

🤔 Interesting take. To be fair, I used to feel the same way, and it used to be popular to hate on !important for no other reason than it often indicated bad code smell, and it could make things less maintainable.

I've since just considered it in terms of syntax consistency. ! is clearly a flag indicator; we're clearly indicating a flag there, but we're writing it like a selector and not a flag. So I don't know it's the worse choice. To me the worse choice is the one we made, which is consistent with nothing, even internally in Less terms, since it's a flag written as a selector.

If you remove the "!important is historically used poorly" emotional attachment, I think on its face, the syntax has nothing wrong with it (other than they only used this syntax for this one thing). It clearly denotes a flag.

@seven-phases-max
Copy link
Member

If I recall correctly earlier we had something like --less-all proposed instead - but it's obviously too verbose... Either way beside the emotional part my only concern is that they still may get to some ! as combinator (even if experimental) and then it's all the same thing again.
A randome idea of the day: What about just --all? (Not conforming to any "custom vendor stuff" CSS rules but still...).

@matthew-dean
Copy link
Member Author

@seven-phases-max As in :extend(something --all)? I think that's a little confusing because of custom properties. So it borrows from command line flags, but then semantically conflicts with other CSS syntax.

@matthew-dean
Copy link
Member Author

I would like to move Less in the direction of less ambiguous parsing. The fact all looks like a normal selector, and the function can contain a selector list forces special processing on the contents of the :extend() function.

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

2 participants