feat(css/ast): Add / to the delimiters (#3402)

This commit is contained in:
Alexander Akait 2022-01-30 07:49:48 +03:00 committed by GitHub
parent b28b636986
commit 2dc31d9d14
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
12 changed files with 1116 additions and 487 deletions

View File

@ -55,6 +55,8 @@ pub enum Value {
pub enum DelimiterValue { pub enum DelimiterValue {
/// `,` /// `,`
Comma, Comma,
/// `/`
Solidus,
} }
#[ast_node("Delimiter")] #[ast_node("Delimiter")]

View File

@ -5375,7 +5375,7 @@ textarea.form-control-lg {
height: 1em; height: 1em;
padding: 0.25em 0.25em; padding: 0.25em 0.25em;
color: #000; color: #000;
/*background: transparent url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='%23000'%3e%3cpath d='M.293.293a1 1 0 011.414 0L8 6.586 14.293.293a1 1 0 111.414 1.414L9.414 8l6.293 6.293a1 1 0 01-1.414 1.414L8 9.414l-6.293 6.293a1 1 0 01-1.414-1.414L6.586 8 .293 1.707a1 1 0 010-1.414z'/%3e%3c/svg%3e") center/1em auto no-repeat;*/ background: transparent url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='%23000'%3e%3cpath d='M.293.293a1 1 0 011.414 0L8 6.586 14.293.293a1 1 0 111.414 1.414L9.414 8l6.293 6.293a1 1 0 01-1.414 1.414L8 9.414l-6.293 6.293a1 1 0 01-1.414-1.414L6.586 8 .293 1.707a1 1 0 010-1.414z'/%3e%3c/svg%3e") center/1em auto no-repeat;
border: 0; border: 0;
border-radius: 0.25rem; border-radius: 0.25rem;
opacity: 0.5; opacity: 0.5;

View File

@ -2409,6 +2409,7 @@ width: 1em;
height: 1em; height: 1em;
padding: 0.25em 0.25em; padding: 0.25em 0.25em;
color: #000; color: #000;
background: transparent url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='%23000'%3e%3cpath d='M.293.293a1 1 0 011.414 0L8 6.586 14.293.293a1 1 0 111.414 1.414L9.414 8l6.293 6.293a1 1 0 01-1.414 1.414L8 9.414l-6.293 6.293a1 1 0 01-1.414-1.414L6.586 8 .293 1.707a1 1 0 010-1.414z'/%3e%3c/svg%3e") center / 1em auto no-repeat;
border: 0; border: 0;
border-radius: 0.25rem; border-radius: 0.25rem;
opacity: 0.5} opacity: 0.5}

File diff suppressed because one or more lines are too long

View File

@ -39,7 +39,19 @@ where
if !eat!(self, " ") if !eat!(self, " ")
&& !is_one_of!( && !is_one_of!(
self, ",", "function", "ident", "percent", "str", "#", "url", "[", "{", "(" self,
",",
"/",
"function",
"ident",
"dimension",
"percent",
"str",
"#",
"url",
"[",
"{",
"("
) )
{ {
if self.ctx.recover_from_property_value if self.ctx.recover_from_property_value
@ -232,6 +244,15 @@ where
})); }));
} }
tok!("/") => {
bump!(self);
return Ok(Value::Delimiter(Delimiter {
span: span!(self, span.lo),
value: DelimiterValue::Solidus,
}));
}
tok!("str") => return Ok(Value::Str(self.parse()?)), tok!("str") => return Ok(Value::Str(self.parse()?)),
tok!("num") => return self.parse_numeric_value(), tok!("num") => return self.parse_numeric_value(),

View File

@ -6,7 +6,9 @@ div {
prop: fn(value); prop: fn(value);
prop: fn(value)fn(value); prop: fn(value)fn(value);
prop: value, value; prop: value, value;
prop: value ,value;
prop: value,value; prop: value,value;
prop: value , value;
prop: 100%100%; prop: 100%100%;
prop: "string""string"; prop: "string""string";
prop: #ccc#ccc; prop: #ccc#ccc;
@ -14,4 +16,8 @@ div {
prop: (value)(value); prop: (value)(value);
prop: {value}{value}; prop: {value}{value};
prop: [value][value]; prop: [value][value];
prop: center/1em;
prop: center/ 1em;
prop: center /1em;
prop: center / 1em;
} }

View File

@ -2,7 +2,7 @@
"type": "Stylesheet", "type": "Stylesheet",
"span": { "span": {
"start": 0, "start": 0,
"end": 358, "end": 499,
"ctxt": 0 "ctxt": 0
}, },
"rules": [ "rules": [
@ -10,7 +10,7 @@
"type": "QualifiedRule", "type": "QualifiedRule",
"span": { "span": {
"start": 0, "start": 0,
"end": 357, "end": 498,
"ctxt": 0 "ctxt": 0
}, },
"prelude": { "prelude": {
@ -66,7 +66,7 @@
"type": "Block", "type": "Block",
"span": { "span": {
"start": 4, "start": 4,
"end": 357, "end": 498,
"ctxt": 0 "ctxt": 0
}, },
"value": [ "value": [
@ -426,7 +426,7 @@
"type": "Declaration", "type": "Declaration",
"span": { "span": {
"start": 159, "start": 159,
"end": 176, "end": 177,
"ctxt": 0 "ctxt": 0
}, },
"property": { "property": {
@ -453,8 +453,8 @@
{ {
"type": "Delimiter", "type": "Delimiter",
"span": { "span": {
"start": 170, "start": 171,
"end": 171, "end": 172,
"ctxt": 0 "ctxt": 0
}, },
"value": "," "value": ","
@ -462,8 +462,8 @@
{ {
"type": "Identifier", "type": "Identifier",
"span": { "span": {
"start": 171, "start": 172,
"end": 176, "end": 177,
"ctxt": 0 "ctxt": 0
}, },
"value": "value", "value": "value",
@ -475,15 +475,115 @@
{ {
"type": "Declaration", "type": "Declaration",
"span": { "span": {
"start": 182, "start": 183,
"end": 196, "end": 200,
"ctxt": 0 "ctxt": 0
}, },
"property": { "property": {
"type": "Identifier", "type": "Identifier",
"span": { "span": {
"start": 182, "start": 183,
"end": 186, "end": 187,
"ctxt": 0
},
"value": "prop",
"raw": "prop"
},
"value": [
{
"type": "Identifier",
"span": {
"start": 189,
"end": 194,
"ctxt": 0
},
"value": "value",
"raw": "value"
},
{
"type": "Delimiter",
"span": {
"start": 194,
"end": 195,
"ctxt": 0
},
"value": ","
},
{
"type": "Identifier",
"span": {
"start": 195,
"end": 200,
"ctxt": 0
},
"value": "value",
"raw": "value"
}
],
"important": null
},
{
"type": "Declaration",
"span": {
"start": 206,
"end": 225,
"ctxt": 0
},
"property": {
"type": "Identifier",
"span": {
"start": 206,
"end": 210,
"ctxt": 0
},
"value": "prop",
"raw": "prop"
},
"value": [
{
"type": "Identifier",
"span": {
"start": 212,
"end": 217,
"ctxt": 0
},
"value": "value",
"raw": "value"
},
{
"type": "Delimiter",
"span": {
"start": 218,
"end": 219,
"ctxt": 0
},
"value": ","
},
{
"type": "Identifier",
"span": {
"start": 220,
"end": 225,
"ctxt": 0
},
"value": "value",
"raw": "value"
}
],
"important": null
},
{
"type": "Declaration",
"span": {
"start": 231,
"end": 245,
"ctxt": 0
},
"property": {
"type": "Identifier",
"span": {
"start": 231,
"end": 235,
"ctxt": 0 "ctxt": 0
}, },
"value": "prop", "value": "prop",
@ -493,15 +593,15 @@
{ {
"type": "Percent", "type": "Percent",
"span": { "span": {
"start": 188, "start": 237,
"end": 192, "end": 241,
"ctxt": 0 "ctxt": 0
}, },
"value": { "value": {
"type": "Number", "type": "Number",
"span": { "span": {
"start": 188, "start": 237,
"end": 191, "end": 240,
"ctxt": 0 "ctxt": 0
}, },
"value": 100.0, "value": 100.0,
@ -511,15 +611,15 @@
{ {
"type": "Percent", "type": "Percent",
"span": { "span": {
"start": 192, "start": 241,
"end": 196, "end": 245,
"ctxt": 0 "ctxt": 0
}, },
"value": { "value": {
"type": "Number", "type": "Number",
"span": { "span": {
"start": 192, "start": 241,
"end": 195, "end": 244,
"ctxt": 0 "ctxt": 0
}, },
"value": 100.0, "value": 100.0,
@ -532,15 +632,15 @@
{ {
"type": "Declaration", "type": "Declaration",
"span": { "span": {
"start": 202, "start": 251,
"end": 224, "end": 273,
"ctxt": 0 "ctxt": 0
}, },
"property": { "property": {
"type": "Identifier", "type": "Identifier",
"span": { "span": {
"start": 202, "start": 251,
"end": 206, "end": 255,
"ctxt": 0 "ctxt": 0
}, },
"value": "prop", "value": "prop",
@ -550,8 +650,8 @@
{ {
"type": "String", "type": "String",
"span": { "span": {
"start": 208, "start": 257,
"end": 216, "end": 265,
"ctxt": 0 "ctxt": 0
}, },
"value": "string", "value": "string",
@ -560,8 +660,8 @@
{ {
"type": "String", "type": "String",
"span": { "span": {
"start": 216, "start": 265,
"end": 224, "end": 273,
"ctxt": 0 "ctxt": 0
}, },
"value": "string", "value": "string",
@ -573,15 +673,15 @@
{ {
"type": "Declaration", "type": "Declaration",
"span": { "span": {
"start": 230, "start": 279,
"end": 244, "end": 293,
"ctxt": 0 "ctxt": 0
}, },
"property": { "property": {
"type": "Identifier", "type": "Identifier",
"span": { "span": {
"start": 230, "start": 279,
"end": 234, "end": 283,
"ctxt": 0 "ctxt": 0
}, },
"value": "prop", "value": "prop",
@ -591,8 +691,8 @@
{ {
"type": "HashValue", "type": "HashValue",
"span": { "span": {
"start": 236, "start": 285,
"end": 240, "end": 289,
"ctxt": 0 "ctxt": 0
}, },
"value": "ccc", "value": "ccc",
@ -601,8 +701,8 @@
{ {
"type": "HashValue", "type": "HashValue",
"span": { "span": {
"start": 240, "start": 289,
"end": 244, "end": 293,
"ctxt": 0 "ctxt": 0
}, },
"value": "ccc", "value": "ccc",
@ -614,15 +714,15 @@
{ {
"type": "Declaration", "type": "Declaration",
"span": { "span": {
"start": 250, "start": 299,
"end": 276, "end": 325,
"ctxt": 0 "ctxt": 0
}, },
"property": { "property": {
"type": "Identifier", "type": "Identifier",
"span": { "span": {
"start": 250, "start": 299,
"end": 254, "end": 303,
"ctxt": 0 "ctxt": 0
}, },
"value": "prop", "value": "prop",
@ -632,15 +732,15 @@
{ {
"type": "Url", "type": "Url",
"span": { "span": {
"start": 256, "start": 305,
"end": 266, "end": 315,
"ctxt": 0 "ctxt": 0
}, },
"name": { "name": {
"type": "Identifier", "type": "Identifier",
"span": { "span": {
"start": 256, "start": 305,
"end": 259, "end": 308,
"ctxt": 0 "ctxt": 0
}, },
"value": "url", "value": "url",
@ -649,8 +749,8 @@
"value": { "value": {
"type": "UrlValueRaw", "type": "UrlValueRaw",
"span": { "span": {
"start": 260, "start": 309,
"end": 265, "end": 314,
"ctxt": 0 "ctxt": 0
}, },
"value": "value", "value": "value",
@ -661,15 +761,15 @@
{ {
"type": "Url", "type": "Url",
"span": { "span": {
"start": 266, "start": 315,
"end": 276, "end": 325,
"ctxt": 0 "ctxt": 0
}, },
"name": { "name": {
"type": "Identifier", "type": "Identifier",
"span": { "span": {
"start": 266, "start": 315,
"end": 269, "end": 318,
"ctxt": 0 "ctxt": 0
}, },
"value": "url", "value": "url",
@ -678,8 +778,8 @@
"value": { "value": {
"type": "UrlValueRaw", "type": "UrlValueRaw",
"span": { "span": {
"start": 270, "start": 319,
"end": 275, "end": 324,
"ctxt": 0 "ctxt": 0
}, },
"value": "value", "value": "value",
@ -693,15 +793,15 @@
{ {
"type": "Declaration", "type": "Declaration",
"span": { "span": {
"start": 282, "start": 331,
"end": 302, "end": 351,
"ctxt": 0 "ctxt": 0
}, },
"property": { "property": {
"type": "Identifier", "type": "Identifier",
"span": { "span": {
"start": 282, "start": 331,
"end": 286, "end": 335,
"ctxt": 0 "ctxt": 0
}, },
"value": "prop", "value": "prop",
@ -711,8 +811,8 @@
{ {
"type": "SimpleBlock", "type": "SimpleBlock",
"span": { "span": {
"start": 288, "start": 337,
"end": 295, "end": 344,
"ctxt": 0 "ctxt": 0
}, },
"name": "(", "name": "(",
@ -720,8 +820,8 @@
{ {
"type": "Identifier", "type": "Identifier",
"span": { "span": {
"start": 289, "start": 338,
"end": 294, "end": 343,
"ctxt": 0 "ctxt": 0
}, },
"value": "value", "value": "value",
@ -732,8 +832,8 @@
{ {
"type": "SimpleBlock", "type": "SimpleBlock",
"span": { "span": {
"start": 295, "start": 344,
"end": 302, "end": 351,
"ctxt": 0 "ctxt": 0
}, },
"name": "(", "name": "(",
@ -741,8 +841,8 @@
{ {
"type": "Identifier", "type": "Identifier",
"span": { "span": {
"start": 296, "start": 345,
"end": 301, "end": 350,
"ctxt": 0 "ctxt": 0
}, },
"value": "value", "value": "value",
@ -756,15 +856,15 @@
{ {
"type": "Declaration", "type": "Declaration",
"span": { "span": {
"start": 308, "start": 357,
"end": 328, "end": 377,
"ctxt": 0 "ctxt": 0
}, },
"property": { "property": {
"type": "Identifier", "type": "Identifier",
"span": { "span": {
"start": 308, "start": 357,
"end": 312, "end": 361,
"ctxt": 0 "ctxt": 0
}, },
"value": "prop", "value": "prop",
@ -774,8 +874,8 @@
{ {
"type": "SimpleBlock", "type": "SimpleBlock",
"span": { "span": {
"start": 314, "start": 363,
"end": 321, "end": 370,
"ctxt": 0 "ctxt": 0
}, },
"name": "{", "name": "{",
@ -783,15 +883,15 @@
{ {
"type": "Tokens", "type": "Tokens",
"span": { "span": {
"start": 315, "start": 364,
"end": 320, "end": 369,
"ctxt": 0 "ctxt": 0
}, },
"tokens": [ "tokens": [
{ {
"span": { "span": {
"start": 315, "start": 364,
"end": 320, "end": 369,
"ctxt": 0 "ctxt": 0
}, },
"token": { "token": {
@ -808,8 +908,8 @@
{ {
"type": "SimpleBlock", "type": "SimpleBlock",
"span": { "span": {
"start": 321, "start": 370,
"end": 328, "end": 377,
"ctxt": 0 "ctxt": 0
}, },
"name": "{", "name": "{",
@ -817,15 +917,15 @@
{ {
"type": "Tokens", "type": "Tokens",
"span": { "span": {
"start": 322, "start": 371,
"end": 327, "end": 376,
"ctxt": 0 "ctxt": 0
}, },
"tokens": [ "tokens": [
{ {
"span": { "span": {
"start": 322, "start": 371,
"end": 327, "end": 376,
"ctxt": 0 "ctxt": 0
}, },
"token": { "token": {
@ -845,15 +945,15 @@
{ {
"type": "Declaration", "type": "Declaration",
"span": { "span": {
"start": 334, "start": 383,
"end": 354, "end": 403,
"ctxt": 0 "ctxt": 0
}, },
"property": { "property": {
"type": "Identifier", "type": "Identifier",
"span": { "span": {
"start": 334, "start": 383,
"end": 338, "end": 387,
"ctxt": 0 "ctxt": 0
}, },
"value": "prop", "value": "prop",
@ -863,8 +963,8 @@
{ {
"type": "SimpleBlock", "type": "SimpleBlock",
"span": { "span": {
"start": 340, "start": 389,
"end": 347, "end": 396,
"ctxt": 0 "ctxt": 0
}, },
"name": "[", "name": "[",
@ -872,8 +972,8 @@
{ {
"type": "Identifier", "type": "Identifier",
"span": { "span": {
"start": 341, "start": 390,
"end": 346, "end": 395,
"ctxt": 0 "ctxt": 0
}, },
"value": "value", "value": "value",
@ -884,8 +984,8 @@
{ {
"type": "SimpleBlock", "type": "SimpleBlock",
"span": { "span": {
"start": 347, "start": 396,
"end": 354, "end": 403,
"ctxt": 0 "ctxt": 0
}, },
"name": "[", "name": "[",
@ -893,8 +993,8 @@
{ {
"type": "Identifier", "type": "Identifier",
"span": { "span": {
"start": 348, "start": 397,
"end": 353, "end": 402,
"ctxt": 0 "ctxt": 0
}, },
"value": "value", "value": "value",
@ -904,6 +1004,274 @@
} }
], ],
"important": null "important": null
},
{
"type": "Declaration",
"span": {
"start": 409,
"end": 425,
"ctxt": 0
},
"property": {
"type": "Identifier",
"span": {
"start": 409,
"end": 413,
"ctxt": 0
},
"value": "prop",
"raw": "prop"
},
"value": [
{
"type": "Identifier",
"span": {
"start": 415,
"end": 421,
"ctxt": 0
},
"value": "center",
"raw": "center"
},
{
"type": "Delimiter",
"span": {
"start": 421,
"end": 422,
"ctxt": 0
},
"value": "/"
},
{
"type": "UnitValue",
"span": {
"start": 422,
"end": 425,
"ctxt": 0
},
"value": {
"type": "Number",
"span": {
"start": 422,
"end": 423,
"ctxt": 0
},
"value": 1.0,
"raw": "1"
},
"unit": {
"span": {
"start": 423,
"end": 425,
"ctxt": 0
},
"value": "em",
"raw": "em"
}
}
],
"important": null
},
{
"type": "Declaration",
"span": {
"start": 431,
"end": 448,
"ctxt": 0
},
"property": {
"type": "Identifier",
"span": {
"start": 431,
"end": 435,
"ctxt": 0
},
"value": "prop",
"raw": "prop"
},
"value": [
{
"type": "Identifier",
"span": {
"start": 437,
"end": 443,
"ctxt": 0
},
"value": "center",
"raw": "center"
},
{
"type": "Delimiter",
"span": {
"start": 443,
"end": 444,
"ctxt": 0
},
"value": "/"
},
{
"type": "UnitValue",
"span": {
"start": 445,
"end": 448,
"ctxt": 0
},
"value": {
"type": "Number",
"span": {
"start": 445,
"end": 446,
"ctxt": 0
},
"value": 1.0,
"raw": "1"
},
"unit": {
"span": {
"start": 446,
"end": 448,
"ctxt": 0
},
"value": "em",
"raw": "em"
}
}
],
"important": null
},
{
"type": "Declaration",
"span": {
"start": 454,
"end": 471,
"ctxt": 0
},
"property": {
"type": "Identifier",
"span": {
"start": 454,
"end": 458,
"ctxt": 0
},
"value": "prop",
"raw": "prop"
},
"value": [
{
"type": "Identifier",
"span": {
"start": 460,
"end": 466,
"ctxt": 0
},
"value": "center",
"raw": "center"
},
{
"type": "Delimiter",
"span": {
"start": 467,
"end": 468,
"ctxt": 0
},
"value": "/"
},
{
"type": "UnitValue",
"span": {
"start": 468,
"end": 471,
"ctxt": 0
},
"value": {
"type": "Number",
"span": {
"start": 468,
"end": 469,
"ctxt": 0
},
"value": 1.0,
"raw": "1"
},
"unit": {
"span": {
"start": 469,
"end": 471,
"ctxt": 0
},
"value": "em",
"raw": "em"
}
}
],
"important": null
},
{
"type": "Declaration",
"span": {
"start": 477,
"end": 495,
"ctxt": 0
},
"property": {
"type": "Identifier",
"span": {
"start": 477,
"end": 481,
"ctxt": 0
},
"value": "prop",
"raw": "prop"
},
"value": [
{
"type": "Identifier",
"span": {
"start": 483,
"end": 489,
"ctxt": 0
},
"value": "center",
"raw": "center"
},
{
"type": "Delimiter",
"span": {
"start": 490,
"end": 491,
"ctxt": 0
},
"value": "/"
},
{
"type": "UnitValue",
"span": {
"start": 492,
"end": 495,
"ctxt": 0
},
"value": {
"type": "Number",
"span": {
"start": 492,
"end": 493,
"ctxt": 0
},
"value": 1.0,
"raw": "1"
},
"unit": {
"span": {
"start": 493,
"end": 495,
"ctxt": 0
},
"value": "em",
"raw": "em"
}
}
],
"important": null
} }
] ]
} }

View File

@ -1,3 +0,0 @@
a {
prop: /;
}

View File

@ -1,132 +0,0 @@
{
"type": "Stylesheet",
"span": {
"start": 0,
"end": 18,
"ctxt": 0
},
"rules": [
{
"type": "QualifiedRule",
"span": {
"start": 0,
"end": 18,
"ctxt": 0
},
"prelude": {
"type": "SelectorList",
"span": {
"start": 0,
"end": 1,
"ctxt": 0
},
"children": [
{
"type": "ComplexSelector",
"span": {
"start": 0,
"end": 1,
"ctxt": 0
},
"children": [
{
"type": "CompoundSelector",
"span": {
"start": 0,
"end": 1,
"ctxt": 0
},
"nestingSelector": null,
"typeSelector": {
"type": "TypeSelector",
"span": {
"start": 0,
"end": 1,
"ctxt": 0
},
"prefix": null,
"name": {
"type": "Identifier",
"span": {
"start": 0,
"end": 1,
"ctxt": 0
},
"value": "a",
"raw": "a"
}
},
"subclassSelectors": []
}
]
}
]
},
"block": {
"type": "Block",
"span": {
"start": 2,
"end": 18,
"ctxt": 0
},
"value": [
{
"type": "Tokens",
"span": {
"start": 8,
"end": 15,
"ctxt": 0
},
"tokens": [
{
"span": {
"start": 8,
"end": 12,
"ctxt": 0
},
"token": {
"Ident": {
"value": "prop",
"raw": "prop"
}
}
},
{
"span": {
"start": 12,
"end": 13,
"ctxt": 0
},
"token": "Colon"
},
{
"span": {
"start": 13,
"end": 14,
"ctxt": 0
},
"token": {
"WhiteSpace": {
"value": " "
}
}
},
{
"span": {
"start": 14,
"end": 15,
"ctxt": 0
},
"token": {
"Delim": {
"value": "/"
}
}
}
]
}
]
}
}
]
}

View File

@ -1,6 +0,0 @@
error: Expected Declaration value
--> $DIR/tests/recovery/delim-token/div/input.css:2:11
|
2 | prop: /;
| ^

View File

@ -125,8 +125,8 @@ define!({
} }
pub enum DelimiterValue { pub enum DelimiterValue {
/// `,`
Comma, Comma,
Solidus,
} }
pub struct Delimiter { pub struct Delimiter {