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

Support CSS @property rule (Less.js 3.0.0) #105

Closed
Fedik opened this issue Jan 9, 2024 · 2 comments
Closed

Support CSS @property rule (Less.js 3.0.0) #105

Fedik opened this issue Jan 9, 2024 · 2 comments
Assignees
Labels
Type: Enhancement New feature or request

Comments

@Fedik
Copy link

Fedik commented Jan 9, 2024

Hi :)

A feature request for @property rule https://developer.mozilla.org/en-US/docs/Web/CSS/@property
It seems already implemented upstream https://github.com/puckowski/less.js/blob/master/packages/less/src/less/tree/property.js

Thank you.

@reedy reedy added the Type: Enhancement New feature or request label Apr 6, 2024
@Krinkle Krinkle changed the title Support @property rule Support @property rule (Less.js 3.x) Apr 13, 2024
@Krinkle Krinkle changed the title Support @property rule (Less.js 3.x) Support @property rule (Less.js 3.5.0) Aug 6, 2024
@Krinkle
Copy link
Member

Krinkle commented Aug 6, 2024

Example:

@property --item-size {
  syntax: "<percentage>";
  inherits: true;
  initial-value: 40%;
}

html {
  --item-size: 20%;
}

.example {
  width: var(--item-size);
}

Upstream Less.js 2.5.3 at http://ecomfe.github.io/est/fiddle/#version=2.5.3&autoprefix=false&est=false&autorun=false

Parse error: directive options not recognised
Line 1: @property --item-size {

This is similar to how Less.php v4.4.0 failed:

lessc: Less_Exception_Chunk: ParseError: Unexpected input in input.less on line 1, column 10
1| @property --item-size {

NOTE: This is unrelated to the Less.js "property" class, which refers to each name/value declaration in a CSS block, for example, color: red is a property.

In Less.js there is also the "Property accessor" feature new in Less.js v3.5.0, which allows any property to be accessed as if it is a Less variable. E.g. color: red can be followed by border-color: $color.

https://lesscss.org/features/#variables-feature-properties-as-variables-new-
https://lesscss.org/features/#detached-rulesets-feature-property-variable-accessors

Finally, there is string interpolation for properties at https://lesscss.org/features/#variables-feature-properties

@foobar: color;

.widget {
  @{foobar}: #0ee;
  background-@{foobar}: #999;
}

But if I understand correctly, this request isn't for any Less.js feature, but rather about CSS's native @property. This is meant to work transparently and won't be documented in Less.js since it is a CSS feature. The bug is that in Less.js 2.5.3, this confused the Less parser because it didn't know about that CSS feature yet.

@Krinkle Krinkle changed the title Support @property rule (Less.js 3.5.0) Support CSS @property rule (Less.js 3.0.0) Aug 6, 2024
@Krinkle Krinkle assigned Krinkle and polishdeveloper and unassigned Krinkle Aug 6, 2024
@Krinkle
Copy link
Member

Krinkle commented Aug 6, 2024

This has been resolved as part of Less.php 5.0, as part of porting over the permissive parsing and arbitrary at-rule support (https://phabricator.wikimedia.org/T368408).

@Krinkle Krinkle closed this as completed Aug 6, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Type: Enhancement New feature or request
Development

No branches or pull requests

4 participants