Skip to content

Regression: unable to unset border-width #319

@sophstad

Description

@sophstad

This works when border is set to a full border property like 1px solid black, but not a keyword like inherit.

Code

import { CSSStyleDeclaration } from "cssstyle"

const style = new CSSStyleDeclaration();
style.border = "inherit";
style.borderWidth = "unset";

Exception

node_modules/.pnpm/cssstyle@6.2.0/node_modules/cssstyle/lib/normalize.js:290
          shorthandObj[key] = parsedValue;
                            ^

TypeError: Cannot create property 'border-width' on string 'inherit'
    at replaceBorderShorthandValue (node_modules/.pnpm/cssstyle@6.2.0/node_modules/cssstyle/lib/normalize.js:290:29)
    at prepareBorderArrayValue (node_modules/.pnpm/cssstyle@6.2.0/node_modules/cssstyle/lib/normalize.js:707:31)
    at prepareBorderProperties (node_modules/.pnpm/cssstyle@6.2.0/node_modules/cssstyle/lib/normalize.js:935:5)
    at CSSStyleDeclaration._borderSetter (node_modules/.pnpm/cssstyle@6.2.0/node_modules/cssstyle/lib/CSSStyleDeclaration.js:449:30)
    at CSSStyleDeclaration.set (node_modules/.pnpm/cssstyle@6.2.0/node_modules/cssstyle/lib/properties/borderWidth.js:29:14)

Node.js v22.18.0

Seems related to #247. Thanks very much!

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