less / less/less.js

attr() declaration with type function breaks parsing

Open
#4,371 7 comments 2 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug
Dominant language
JavaScript
Stars
17k
Forks
3.4k
Avg merge
7h 42m
Merged PRs (30d)
26

Description

To reproduce:

img {
    aspect-ratio: attr(width type(<number>)) / attr(height type(<number>));
}

Current behavior:

An exception: "Could not parse call arguments or missing ')'" is thrown.

Expected behavior:

img {
    aspect-ratio: attr(width type(<number>)) / attr(height type(<number>));
}

should be rendered

Environment information:

  • less version: 4.2.2
  • nodejs version: 22.17.0
  • operating system: macos

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by running the supplied LESS reproduction with less 4.2.2 on Node.js 22.17.0 and trace the parser entry point for attr() arguments, including type() syntax. Done means it compiles without the reported exception and produces the expected CSS declaration for both attr() calls.

Written by the indexing model from the issue text.

Assessment

Tech stack
css, javascript
Domain
compilers
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
55/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.