Skip to content

Commit fd4400c

Browse files
committed
fix typo
1 parent 7ec697f commit fd4400c

10 files changed

Lines changed: 57 additions & 20 deletions

File tree

plugins/postcss-syntax-descriptor-syntax-production/CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
# Changes to PostCSS Syntax Descriptor Syntax Production
22

3+
### Unreleased (patch)
4+
5+
- Fix typo
6+
37
### 1.0.0
48

59
_December 27, 2025_

plugins/postcss-syntax-descriptor-syntax-production/README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ npm install @csstools/postcss-syntax-descriptor-syntax-production --save-dev
2020
@property --color {
2121
inherits: true;
2222
initial-value: black;
23-
color: "<color>";
23+
syntax: "<color>";
2424
}
2525
```
2626

@@ -77,7 +77,7 @@ postcssSyntaxDescriptorSyntaxProduction({ preserve: true })
7777
@property --color {
7878
inherits: true;
7979
initial-value: black;
80-
color: "<color>";
80+
syntax: "<color>";
8181
syntax: <color>;
8282
}
8383
```
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
"use strict";var e=require("@csstools/css-tokenizer");const s=/^property$/i,c=/^syntax$/i,creator=a=>{const t=Object.assign({preserve:!1},a);return{postcssPlugin:"postcss-syntax-descriptor-syntax-production",Declaration(a){if(!c.test(a.prop))return;if(!a.parent||"atrule"!==a.parent.type)return;if(!s.test(a.parent.name))return;const o=a.value,r=e.tokenize({css:a.value});let n="";r.forEach(s=>{e.isTokenComment(s)||(e.isTokenWhitespace(s)?n+=" ":n+=s[1])});let i='"';for(const e of n){const s=e.codePointAt(0);if(void 0!==s)switch(s){case 0:i+=String.fromCodePoint(65533);break;case 34:case 92:i+="\\"+String.fromCodePoint(s);break;case 1:case 2:case 3:case 4:case 5:case 6:case 7:case 8:case 9:case 10:case 11:case 12:case 13:case 14:case 15:case 16:case 17:case 18:case 19:case 20:case 21:case 22:case 23:case 24:case 25:case 26:case 27:case 28:case 29:case 30:case 31:case 127:i+="\\"+s.toString(16)+" ";break;default:i+=String.fromCodePoint(s)}}i+='"',o!==i&&(a.cloneBefore({prop:"color",value:i}),t.preserve||a.remove())}}};creator.postcss=!0,module.exports=creator;
1+
"use strict";var e=require("@csstools/css-tokenizer");const s=/^property$/i,t=/^syntax$/i,creator=c=>{const a=Object.assign({preserve:!1},c);return{postcssPlugin:"postcss-syntax-descriptor-syntax-production",Declaration(c){if(!t.test(c.prop))return;if(!c.parent||"atrule"!==c.parent.type)return;if(!s.test(c.parent.name))return;const r=c.prev();if(r&&"decl"===r.type&&t.test(r.prop))return;const o=c.value,n=e.tokenize({css:c.value}),i=n.filter(s=>!(e.isTokenWhiteSpaceOrComment(s)||e.isTokenEOF(s)));if(1===i.length&&e.isTokenString(i[0]))return;let p="";n.forEach(s=>{e.isTokenComment(s)||(e.isTokenWhitespace(s)?p+=" ":p+=s[1])});let u='"';for(const e of p){const s=e.codePointAt(0);if(void 0!==s)switch(s){case 0:u+=String.fromCodePoint(65533);break;case 34:case 92:u+="\\"+String.fromCodePoint(s);break;case 1:case 2:case 3:case 4:case 5:case 6:case 7:case 8:case 9:case 10:case 11:case 12:case 13:case 14:case 15:case 16:case 17:case 18:case 19:case 20:case 21:case 22:case 23:case 24:case 25:case 26:case 27:case 28:case 29:case 30:case 31:case 127:u+="\\"+s.toString(16)+" ";break;default:u+=String.fromCodePoint(s)}}u+='"',o!==u&&(c.cloneBefore({value:u}),a.preserve||c.remove())}}};creator.postcss=!0,module.exports=creator;
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
import{tokenize as e,isTokenComment as s,isTokenWhitespace as a}from"@csstools/css-tokenizer";const c=/^property$/i,t=/^syntax$/i,creator=r=>{const o=Object.assign({preserve:!1},r);return{postcssPlugin:"postcss-syntax-descriptor-syntax-production",Declaration(r){if(!t.test(r.prop))return;if(!r.parent||"atrule"!==r.parent.type)return;if(!c.test(r.parent.name))return;const n=r.value,i=e({css:r.value});let p="";i.forEach(e=>{s(e)||(a(e)?p+=" ":p+=e[1])});let f='"';for(const e of p){const s=e.codePointAt(0);if(void 0!==s)switch(s){case 0:f+=String.fromCodePoint(65533);break;case 34:case 92:f+="\\"+String.fromCodePoint(s);break;case 1:case 2:case 3:case 4:case 5:case 6:case 7:case 8:case 9:case 10:case 11:case 12:case 13:case 14:case 15:case 16:case 17:case 18:case 19:case 20:case 21:case 22:case 23:case 24:case 25:case 26:case 27:case 28:case 29:case 30:case 31:case 127:f+="\\"+s.toString(16)+" ";break;default:f+=String.fromCodePoint(s)}}f+='"',n!==f&&(r.cloneBefore({prop:"color",value:f}),o.preserve||r.remove())}}};creator.postcss=!0;export{creator as default};
1+
import{tokenize as e,isTokenWhiteSpaceOrComment as s,isTokenEOF as a,isTokenString as c,isTokenComment as t,isTokenWhitespace as r}from"@csstools/css-tokenizer";const o=/^property$/i,n=/^syntax$/i,creator=i=>{const p=Object.assign({preserve:!1},i);return{postcssPlugin:"postcss-syntax-descriptor-syntax-production",Declaration(i){if(!n.test(i.prop))return;if(!i.parent||"atrule"!==i.parent.type)return;if(!o.test(i.parent.name))return;const f=i.prev();if(f&&"decl"===f.type&&n.test(f.prop))return;const l=i.value,u=e({css:i.value}),d=u.filter(e=>!(s(e)||a(e)));if(1===d.length&&c(d[0]))return;let v="";u.forEach(e=>{t(e)||(r(e)?v+=" ":v+=e[1])});let g='"';for(const e of v){const s=e.codePointAt(0);if(void 0!==s)switch(s){case 0:g+=String.fromCodePoint(65533);break;case 34:case 92:g+="\\"+String.fromCodePoint(s);break;case 1:case 2:case 3:case 4:case 5:case 6:case 7:case 8:case 9:case 10:case 11:case 12:case 13:case 14:case 15:case 16:case 17:case 18:case 19:case 20:case 21:case 22:case 23:case 24:case 25:case 26:case 27:case 28:case 29:case 30:case 31:case 127:g+="\\"+s.toString(16)+" ";break;default:g+=String.fromCodePoint(s)}}g+='"',l!==g&&(i.cloneBefore({value:g}),p.preserve||i.remove())}}};creator.postcss=!0;export{creator as default};

plugins/postcss-syntax-descriptor-syntax-production/src/index.ts

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { isTokenComment, isTokenWhitespace, tokenize } from '@csstools/css-tokenizer';
1+
import { isTokenComment, isTokenEOF, isTokenString, isTokenWhitespace, isTokenWhiteSpaceOrComment, tokenize } from '@csstools/css-tokenizer';
22
import type { PluginCreator } from 'postcss';
33

44
/** postcss-syntax-descriptor-syntax-production plugin options */
@@ -35,9 +35,22 @@ const creator: PluginCreator<pluginOptions> = (opts?: pluginOptions) => {
3535
return;
3636
}
3737

38+
const prev = decl.prev();
39+
if (prev && prev.type === 'decl' && IS_SYNTAX_REGEX.test(prev.prop)) {
40+
return;
41+
}
42+
3843
const originalValue = decl.value;
3944
const tokens = tokenize({ css: decl.value });
4045

46+
const meaningfulTokens = tokens.filter((x) => {
47+
return !(isTokenWhiteSpaceOrComment(x) || isTokenEOF(x));
48+
});
49+
50+
if (meaningfulTokens.length === 1 && isTokenString(meaningfulTokens[0])) {
51+
return;
52+
}
53+
4154
let stringValue = '';
4255
tokens.forEach((token) => {
4356
if (isTokenComment(token)) return;
@@ -114,7 +127,6 @@ const creator: PluginCreator<pluginOptions> = (opts?: pluginOptions) => {
114127
}
115128

116129
decl.cloneBefore({
117-
prop: 'color',
118130
value: serialized,
119131
});
120132

plugins/postcss-syntax-descriptor-syntax-production/test/basic.css

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,3 +35,10 @@
3535
initial-value: black;
3636
syntax: <color> /* a comment */ | </* a comment */string> | <number>;
3737
}
38+
39+
@property --color {
40+
inherits: true;
41+
initial-value: black;
42+
syntax: "<color-fallback>";
43+
syntax: <color>;
44+
}
Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,35 +1,42 @@
11
@property --color {
22
inherits: true;
33
initial-value: black;
4-
color: "<color>";
4+
syntax: "<color>";
55
}
66

77
@property --multi-line {
88
inherits: true;
99
initial-value: black;
10-
color: "<color> | <string> | <number>";
10+
syntax: "<color> | <string> | <number>";
1111
}
1212

1313
@property --box-shadow {
1414
inherits: true;
1515
initial-value: black;
16-
color: "[ inset? && <length>{2,4} && <color>? ]# | none";
16+
syntax: "[ inset? && <length>{2,4} && <color>? ]# | none";
1717
}
1818

1919
@property --quoted {
2020
inherits: true;
2121
initial-value: black;
22-
color: "'\"' <ident> '\"'";
22+
syntax: "'\"' <ident> '\"'";
2323
}
2424

2525
@property --function {
2626
inherits: true;
2727
initial-value: black;
28-
color: "example(first?, second?, third?)";
28+
syntax: "example(first?, second?, third?)";
2929
}
3030

3131
@property --comments {
3232
inherits: true;
3333
initial-value: black;
34-
color: "<color> | <string> | <number>";
34+
syntax: "<color> | <string> | <number>";
35+
}
36+
37+
@property --color {
38+
inherits: true;
39+
initial-value: black;
40+
syntax: "<color-fallback>";
41+
syntax: <color>;
3542
}
Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
@property --color {
22
inherits: true;
33
initial-value: black;
4-
color: "<color>";
4+
syntax: "<color>";
55
syntax: <color>;
66
}
77

88
@property --multi-line {
99
inherits: true;
1010
initial-value: black;
11-
color: "<color> | <string> | <number>";
11+
syntax: "<color> | <string> | <number>";
1212
syntax: <color> |
1313
<string> |
1414
<number>;
@@ -17,27 +17,34 @@
1717
@property --box-shadow {
1818
inherits: true;
1919
initial-value: black;
20-
color: "[ inset? && <length>{2,4} && <color>? ]# | none";
20+
syntax: "[ inset? && <length>{2,4} && <color>? ]# | none";
2121
syntax: [ inset? && <length>{2,4} && <color>? ]# | none;
2222
}
2323

2424
@property --quoted {
2525
inherits: true;
2626
initial-value: black;
27-
color: "'\"' <ident> '\"'";
27+
syntax: "'\"' <ident> '\"'";
2828
syntax: '"' <ident> '"';
2929
}
3030

3131
@property --function {
3232
inherits: true;
3333
initial-value: black;
34-
color: "example(first?, second?, third?)";
34+
syntax: "example(first?, second?, third?)";
3535
syntax: example(first?, second?, third?);
3636
}
3737

3838
@property --comments {
3939
inherits: true;
4040
initial-value: black;
41-
color: "<color> | <string> | <number>";
41+
syntax: "<color> | <string> | <number>";
4242
syntax: <color> /* a comment */ | </* a comment */string> | <number>;
4343
}
44+
45+
@property --color {
46+
inherits: true;
47+
initial-value: black;
48+
syntax: "<color-fallback>";
49+
syntax: <color>;
50+
}
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
@property --color {
22
inherits: true;
33
initial-value: black;
4-
color: "<color>";
4+
syntax: "<color>";
55
}
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
@property --color {
22
inherits: true;
33
initial-value: black;
4-
color: "<color>";
4+
syntax: "<color>";
55
syntax: <color>;
66
}

0 commit comments

Comments
 (0)