Fix css name sanitization

This commit is contained in:
Zoe Roux
2023-01-07 13:33:46 +09:00
parent a7e17b35e0
commit 70c9d8d9d5
3 changed files with 4 additions and 2 deletions

View File

@@ -79,6 +79,7 @@ function App() {
backgroundColor: "#fff",
alignItems: "center",
justifyContent: "center",
elevation: 6,
})}
>
<Text>Open up App.tsx to start working on your app!</Text>

View File

@@ -1,6 +1,6 @@
{
"name": "yoshiki",
"version": "0.3.3",
"version": "0.3.4",
"author": "Zoe Roux <zoe.roux@sdg.moe> (https://github.com/AnonymusRaccoon)",
"license": "MIT",
"keywords": [

View File

@@ -43,7 +43,7 @@ const stateMapper: {
const sanitize = (className: unknown) => {
const name = typeof className === "string" ? className : JSON.stringify(className);
if (name === undefined) return "undefined";
return name.replaceAll(/[^\w-_]/g, "");
return name.replaceAll(/[^\w\d_]/g, "");
};
type PreprocessBlockFunction = (block: { [key: string]: unknown }) => { [key: string]: unknown };
@@ -67,6 +67,7 @@ const generateClass = (
: [`${cssKey}: ${nValue};`];
})
.join(" ");
if (!block.length) return [];
return [[className, addCssContext(className, `{ ${block} }`)]];
};