Skip to content

Incorrect parsing on font-family with consecutive, leading, or trailing commas #309

@simon-paris

Description

@simon-paris

Summary

Extra commas in font-family should cause errors. It parses them as an array containing empty strings ",," -> ["", "", ""], but unquoted empty strings aren't allowed.

e.g. Setting font-family to Arial, should fail, but actually results in Arial, (with a space inserted after each comma).

const el = document.createElement("input");
el.style.fontFamily = "Arial,";
expect(el.style.fontFamily).toBe(""); // actually: "Arial, "

More examples: ,Arial Arial, Arial,,Arial ,,

Expected

It should be an error. The result should be "".

Actual

It succeeds, and inserts a space after each comma.

Version

# pnpm why cssstyle
jsdom 28.1.0
└── cssstyle 6.0.1

Also affects 5.3.7.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions