11ty / 11ty/webc

webc:scoped and `lch()`

Open
#82 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug-in-dependency on-hold
Dominant language
JavaScript
Stars
1.4k
Forks
46
Avg merge
10m
Merged PRs (30d)
2

Description

cc @georgedoescode

TL;DR

The synopsis:

Currently <style webc:scoped="my-prefix">div { color: lch(97% 44.2% 240); }</style> returns .my-prefix div{color:lch(97% 44.2%240)}.

This is independent of WebC and is the same in our raw upstream dependency output from css-tree https://www.npmjs.com/package/css-tree

import { generate, parse, walk } from "css-tree";
let ast = parse(str);

console.log(generate(ast));

This occurs with both spec or safe mode in the generate method. https://github.com/csstree/csstree/blob/HEAD/docs/generate.md#mode

Notably there is only one browser that supports lch right now so I plugged that value into Safari and it was invalid there—THOUGH confusingly I did find evidence of that same format in the spec 😅 at https://w3c.github.io/csswg-drafts/css-color/#ex-lch-samples

image

All that said, using an lch() without a percentage as the second value gives back the same issue in css-tree:

div { color: lch(67.5345% 42.5 258.2); }

/* returns */
div { color: lch(67.5345%42.5 258.2); }

I filed the above test case upstream at https://github.com/csstree/csstree/issues/209

All THAT said, both the preprocessed value and the postprocessed value render fine in Safari.

Contributor guide

No contributing guide indexed for this repository

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

Reproduce the examples in the issue using css-tree's parse and generate APIs, including both generator modes, and compare the output with the expected whitespace in lch() values. Read the linked css-tree issue 209 first; done means the dependency or its integration preserves valid lch() syntax without breaking the scoped style output.

Written by the indexing model from the issue text.

Assessment

Tech stack
css, javascript
Domain
frontend, web-dev
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.