Skip to content

attr() declaration with type function breaks parsing #4371

Open

Description

@janschoenherr

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

Activity

  1. dosubot commented on Oct 13, 2025

    @dosubot
  2. puckowski commented on Oct 16, 2025

    @puckowski
    Contributor

    Thank you for the bug report @janschoenherr

    I'll try to experiment this weekend and see if I can come up with a solution.

  3. rohan45327 commented on Oct 20, 2025

    @rohan45327

    Hi @janschoenherr I have been reviewed the bug and I also earlier encountered the same bug :

    `img {

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

    }`

    To fix this try ~" " by wrapping the expression in :

    `~"img{

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

    }"`

    this will tell less to treat as raw CSS. and The compiler will no longer throw Could not parse call arguments or missing ')' error
    The resulting CSS works as expected in all modern browsers.

  4. janschoenherr commented on Oct 22, 2025

    @janschoenherr
    Author

    Hi @rohan45327,

    thanks, that's what we currently do with uikit. It would still be nice, if we wouldn't have to use the workaround.

  5. matthew-dean commented on Oct 23, 2025

    @matthew-dean
    Member

    @janschoenherr Can you link to the spec where type(<number>) (specifically <number>) is now a valid value?

  6. janschoenherr commented on Oct 27, 2025

    @janschoenherr
    Author

    @matthew-dean This is still in draft: https://drafts.csswg.org/css-values-5/#attr-notation

    Currently only Chrome supports it. I understand, if you want to delay supporting it until the spec is final.

    https://wpt.fyi/results/css/css-values/attr-all-types.html?label=experimental&label=master&aligned&q=attr-all-types

  7. matthew-dean commented on Mar 10, 2026

    @matthew-dean
    Member

    @janschoenherr Until Firefox & Safari support it, it makes it effectively an unusable property.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions