fix(issue:4331) and keyword treated as function
What:
Fix for issue #4331
The and keyword was being treated as a function call starting Less 4.2.1 which introduced selector generation problems.
Why:
The following Less:
@media screen and(max-width:1280px) {
.form-process-table {
width: 1200px;
> div {
width: 960px;
}
}
}
would fail to insert a space after and Keyword like it did in Less 4.2.0. This would cause selector issues in the resulting CSS.
I simultaneously had to add a function definition for size to avoid regressions with container queries when fixing this and issue.
Checklist:
- [ ] Documentation
- [x] Added/updated unit tests
- [x] Code complete
Workaround: Ensure a space is present after and in the source Less.
Looks like there are CI issues (may be resolved by https://github.com/less/less.js/pull/4322):
╔═════════════════════════════════════════════════════════════════════════╗
║ Looks like Playwright Test or Playwright was just installed or updated. ║
║ Please run the following command to download new browsers: ║
║ ║
║ pnpm exec playwright install ║
║ ║
║ <3 Playwright Team ║
╚═════════════════════════════════════════════════════════════════════════╝
What change made it be treated like a function?
What change made it be treated like a function?
https://github.com/less/less.js/pull/4237
The addition of declarationCall which must match functions before keywords (otherwise functions may be identified incorrectly as keywords) caused the regression:
e = entities.declarationCall.bind(this)() || entities.keyword() || entities.variable() || entities.mixinLookup();
#4237 was potentially relying on a weak regex:
validCall = parserInput.$re(/^[\w]+\(/);
though instead of fiddling with a regex in this PR we now check the function registry to sure what we are looking at is a function, otherwise we can later try to parse as keyword.
@puckowski Seems like I'm getting Playwright errors even after merging the other one 🤔
I pulled latest to get CI changes from https://github.com/less/less.js/pull/4333 and pushed again. CI is good now. I suspect any old PRs running into this issue will have to pull latest master and repush or rebase.
I suspect old pnpm-lock.yaml files in these older branches is what caused the failures when you reran.
@matthew-dean
What do you think about merging this PR?
I'd like to get this fix out the door soon to resolve the regression. Subsequent PRs can improve the solution.
@matthew-dean