Skip to content

Commit 620cdec

Browse files
committed
drop css subs
1 parent 84d325a commit 620cdec

File tree

1 file changed

+1
-41
lines changed

1 file changed

+1
-41
lines changed
Lines changed: 1 addition & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -1,43 +1,3 @@
1-
import { Expression } from "typescript";
21
import { VirtualAstDocument } from "./virtual-ast-document";
32

4-
export class VirtualAstCssDocument extends VirtualAstDocument {
5-
protected substituteExpression(expression: Expression, prev: string, next: string | undefined): string {
6-
const hasLeftColon = prev.match(/:[^;{]*\${$/) != null;
7-
const hasRightColon = next != null && next.match(/^}\s*:\s+/) != null;
8-
const hasRightSemicolon = next != null && next.match(/^}\s*;/) != null;
9-
const hasRightPercentage = next != null && next.match(/^}%/) != null;
10-
11-
// Inspired by https://github.com/Microsoft/typescript-styled-plugin/blob/909d4f17d61562fe77f24587ea443713b8da851d/src/_substituter.ts#L62
12-
// If this substitution contains both a property and a key, replace it with "$_:_"
13-
// Example:
14-
// div {
15-
// ${unsafeCSS("color: red)};
16-
// }
17-
if (hasRightSemicolon && !hasLeftColon) {
18-
const prefix = "$_:_";
19-
return `${prefix}${this.substitutionIndex++}`;
20-
}
21-
22-
// If there is "%" to the right of this substitution, replace with a number, because the parser expects a number unit
23-
// Example:
24-
// div {
25-
// transform-origin: ${x}% ${y}%;
26-
// }
27-
else if (hasRightPercentage) {
28-
return `0${this.substitutionIndex++}`;
29-
}
30-
31-
// If there is a ": " to the right of this substitution, replace it with an identifier
32-
// Example:
33-
// div {
34-
// ${unsafeCSS("color")}: red
35-
// }
36-
else if (hasRightColon) {
37-
return `$_${this.substitutionIndex++}`;
38-
}
39-
40-
// Else replace with an identifier "_"
41-
return `_${this.substitutionIndex++}`;
42-
}
43-
}
3+
export class VirtualAstCssDocument extends VirtualAstDocument {}

0 commit comments

Comments
 (0)