Skip to content

background shorthand produces invalid CSS #165

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

Open
nsaunders opened this issue May 20, 2022 · 0 comments
Open

background shorthand produces invalid CSS #165

nsaunders opened this issue May 20, 2022 · 0 comments
Labels
type: bug Something that should function correctly isn't. type: enhancement A new feature or addition.

Comments

@nsaunders
Copy link
Member

nsaunders commented May 20, 2022

Describe the bug

The background "shorthand" function produces invalid CSS.

To Reproduce

For example...

background (contain /\ placed sideCenter sideCenter)

...is rendered as...

background: contain center center

...even though the correct syntax, per the CSS Backgrounds and Borders Module Level 3 specification, is...

background: center center/contain

Another example relates to background-origin and background-clip:

background (boxClip paddingBox /\ origin contentBox)

...is rendered as (comment mine, per spec)...

background: padding-box content-box /* background-origin background-clip */

Notice that the background-origin and background-clip values are reversed.

Proposal

I'm not sure the background "shorthand" function saves much code, if any at all, compared to setting the constituent properties individually. At the same time, it doesn't offer much type safety and, as demonstrated, produces inaccurate results.

For the moment, I lean toward scrapping this API altogether.

Alternatively:

  1. The function must produce accurate results, even if that means the API changes a bit.
  2. Ideally, the API should provide meaningful type safety, for example preventing a <bg-size> in the absence of a <bg-position> (spec).
  3. The font shorthand property should probably be reimplemented with a similar API at the same time to avoid inconsistent API design.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: bug Something that should function correctly isn't. type: enhancement A new feature or addition.
Development

No branches or pull requests

1 participant