-
-
Notifications
You must be signed in to change notification settings - Fork 29
Description
In development we're using $displayName so this issue is hidden, but once we built for production I noticed that class names starting with digits do not work. I would prefer to have an option to keep $displayName in production. But the underlying issue (hashes can start with digit) might also need to be fixed?
import { create } from "https://esm.run/free-style";
// Create a stylesheet instance.
const sheet = create();
const backgroundStyle = sheet.registerStyle({
backgroundColor: "red",
});
const textSyles = sheet.getStyles();
console.log(backgroundStyle); // 14svl5e
console.log(textSyles); // .14svl5e{background-color:red}– demo: https://www.val.town/x/forresto/free-style-bug/code/main.ts
In CSS1, a class name could start with a digit (".55ft"), unless it was a dimension (".55in"). In CSS2, such classes are parsed as unknown dimensions (to allow for future additions of new units) To make 14svl5e a valid class, CSS2 requires the first digit to be escaped: .\31 4svl5e [14svl5e]
– via https://jigsaw.w3.org/css-validator/#validate_by_input
A simple fix would be prefix generated names with an underscore, so _14svl5e and ._14svl5e{background-color:red}