Skip to content

Commit f36d867

Browse files
authored
fix: caret-color parsing for unparsed declarations (#86)
1 parent 4af17f5 commit f36d867

File tree

4 files changed

+7
-13
lines changed

4 files changed

+7
-13
lines changed

src/compiler/__tests__/declarations.test.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import { compile } from "../compiler";
22

33
const tests = [
4+
["caret-color: black", [{ d: [["#000", ["cursorColor"]]], s: [1, 1] }]],
45
["stroke: black;", [{ d: [["#000", ["stroke"]]], s: [1, 1] }]],
56
] as const;
67

src/compiler/atRules.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,10 @@ function isPropAtRule(rule: Rule | PropAtRule): rule is PropAtRule {
7979
}
8080

8181
export function parsePropAtRule(rules?: (Rule | PropAtRule)[]) {
82-
const mapping: StyleRuleMapping = {};
82+
// Include any default mapping here
83+
const mapping: StyleRuleMapping = {
84+
"caret-color": ["cursorColor"],
85+
};
8386

8487
if (!rules) return mapping;
8588

src/compiler/declarations.ts

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@ const parsers: {
142142
"border-width": parseBorderWidth,
143143
"bottom": parseSizeDeclaration,
144144
"box-shadow": parseBoxShadow,
145-
"caret-color": parseCaretColor,
145+
"caret-color": parseColorOrAutoDeclaration,
146146
"color": parseFontColorDeclaration,
147147
"column-gap": parseGap,
148148
"container": parseContainer,
@@ -244,17 +244,6 @@ const parsers: {
244244

245245
const validProperties = new Set(Object.keys(parsers));
246246

247-
function parseCaretColor(
248-
declaration: DeclarationType<"caret-color">,
249-
builder: StylesheetBuilder,
250-
) {
251-
builder.addMapping({ [declaration.property]: ["cursorColor"] });
252-
builder.addDescriptor(
253-
"caret-color",
254-
parseColorOrAutoDeclaration(declaration, builder),
255-
);
256-
}
257-
258247
export function parseDeclaration(
259248
declaration: Declaration,
260249
builder: StylesheetBuilder,

src/compiler/stylesheet.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ export class StylesheetBuilder {
5050
private ruleTemplate: StyleRule = {
5151
s: [],
5252
},
53+
// Any default mapping should be included in the @prop parsing
5354
private mapping: StyleRuleMapping = {},
5455
public descriptorProperty?: string,
5556
private shared: {

0 commit comments

Comments
 (0)