diff --git a/Cargo.lock b/Cargo.lock index 14aa4066873..ca915dcbf24 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2500,7 +2500,7 @@ dependencies = [ [[package]] name = "swc_css" -version = "0.14.0" +version = "0.15.0" dependencies = [ "swc_css_ast", "swc_css_codegen", @@ -2511,7 +2511,7 @@ dependencies = [ [[package]] name = "swc_css_ast" -version = "0.13.0" +version = "0.14.0" dependencies = [ "is-macro", "serde", @@ -2522,7 +2522,7 @@ dependencies = [ [[package]] name = "swc_css_codegen" -version = "0.12.0" +version = "0.13.0" dependencies = [ "auto_impl", "bitflags", @@ -2548,7 +2548,7 @@ dependencies = [ [[package]] name = "swc_css_parser" -version = "0.14.1" +version = "0.15.0" dependencies = [ "bitflags", "lexical", @@ -2564,7 +2564,7 @@ dependencies = [ [[package]] name = "swc_css_utils" -version = "0.10.0" +version = "0.11.0" dependencies = [ "swc_atoms 0.2.8", "swc_common", @@ -2574,7 +2574,7 @@ dependencies = [ [[package]] name = "swc_css_visit" -version = "0.12.0" +version = "0.13.0" dependencies = [ "swc_atoms 0.2.8", "swc_common", @@ -3140,7 +3140,7 @@ dependencies = [ [[package]] name = "swc_stylis" -version = "0.11.0" +version = "0.12.0" dependencies = [ "swc_atoms 0.2.8", "swc_common", diff --git a/css/Cargo.toml b/css/Cargo.toml index b57a34fef3a..60586a9cc55 100644 --- a/css/Cargo.toml +++ b/css/Cargo.toml @@ -6,11 +6,11 @@ edition = "2018" license = "Apache-2.0/MIT" name = "swc_css" repository = "https://github.com/swc-project/swc.git" -version = "0.14.0" +version = "0.15.0" [dependencies] -swc_css_ast = {version = "0.13.0", path = "./ast"} -swc_css_codegen = {version = "0.12.0", path = "./codegen"} -swc_css_parser = {version = "0.14.0", path = "./parser"} -swc_css_utils = {version = "0.10.0", path = "./utils/"} -swc_css_visit = {version = "0.12.0", path = "./visit"} +swc_css_ast = {version = "0.14.0", path = "./ast"} +swc_css_codegen = {version = "0.13.0", path = "./codegen"} +swc_css_parser = {version = "0.15.0", path = "./parser"} +swc_css_utils = {version = "0.11.0", path = "./utils/"} +swc_css_visit = {version = "0.13.0", path = "./visit"} diff --git a/css/ast/Cargo.toml b/css/ast/Cargo.toml index 4ce7f26942f..b26087d5409 100644 --- a/css/ast/Cargo.toml +++ b/css/ast/Cargo.toml @@ -6,7 +6,7 @@ edition = "2018" license = "Apache-2.0/MIT" name = "swc_css_ast" repository = "https://github.com/swc-project/swc.git" -version = "0.13.0" +version = "0.14.0" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html diff --git a/css/ast/src/token.rs b/css/ast/src/token.rs index ed9b26db074..360cef35a24 100644 --- a/css/ast/src/token.rs +++ b/css/ast/src/token.rs @@ -86,9 +86,6 @@ pub enum Token { /// `*` Asterisk, - /// `.` - Dot, - /// `#` Hash { is_id: bool, @@ -123,12 +120,6 @@ pub enum Token { /// `=` Equals, - /// `+` - Plus, - - /// `-` - Minus, - /// `/` Div, diff --git a/css/codegen/Cargo.toml b/css/codegen/Cargo.toml index b991002f3be..fd11ce16c9a 100644 --- a/css/codegen/Cargo.toml +++ b/css/codegen/Cargo.toml @@ -6,17 +6,17 @@ edition = "2018" license = "Apache-2.0/MIT" name = "swc_css_codegen" repository = "https://github.com/swc-project/swc.git" -version = "0.12.0" +version = "0.13.0" [dependencies] auto_impl = "0.4.1" bitflags = "1.3.2" swc_atoms = {version = "0.2.7", path = "../../atoms"} swc_common = {version = "0.13.0", path = "../../common"} -swc_css_ast = {version = "0.13.0", path = "../ast/"} +swc_css_ast = {version = "0.14.0", path = "../ast/"} swc_css_codegen_macros = {version = "0.2.0", path = "macros/"} [dev-dependencies] -swc_css_parser = {version = "0.14.0", path = "../parser"} -swc_css_visit = {version = "0.12.0", path = "../visit"} +swc_css_parser = {version = "0.15.0", path = "../parser"} +swc_css_visit = {version = "0.13.0", path = "../visit"} testing = {version = "0.14.0", path = "../../testing"} diff --git a/css/codegen/src/lib.rs b/css/codegen/src/lib.rs index d424da5335c..6601b34487a 100644 --- a/css/codegen/src/lib.rs +++ b/css/codegen/src/lib.rs @@ -536,9 +536,6 @@ where Token::Asterisk => { punct!(self, span, "*"); } - Token::Dot => { - punct!(self, span, "."); - } Token::Hash { value, .. } => { punct!(self, "#"); self.wr.write_ident(Some(span), &value, true)?; @@ -570,12 +567,6 @@ where Token::Equals => { punct!(self, span, "="); } - Token::Plus => { - punct!(self, span, "+"); - } - Token::Minus => { - punct!(self, span, "-"); - } Token::Div => { punct!(self, span, "/"); } diff --git a/css/parser/Cargo.toml b/css/parser/Cargo.toml index bc1bfafd175..b34d7b45ae6 100644 --- a/css/parser/Cargo.toml +++ b/css/parser/Cargo.toml @@ -6,7 +6,7 @@ edition = "2018" license = "Apache-2.0/MIT" name = "swc_css_parser" repository = "https://github.com/swc-project/swc.git" -version = "0.14.1" +version = "0.15.0" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html [features] @@ -17,11 +17,11 @@ bitflags = "1.2.1" lexical = "5.2.2" swc_atoms = {version = "0.2.7", path = "../../atoms"} swc_common = {version = "0.13.0", path = "../../common"} -swc_css_ast = {version = "0.13.0", path = "../ast"} +swc_css_ast = {version = "0.14.0", path = "../ast"} unicode-xid = "0.2.2" [dev-dependencies] serde = "1.0.127" serde_json = "1.0.66" -swc_css_visit = {version = "0.12.0", path = "../visit"} +swc_css_visit = {version = "0.13.0", path = "../visit"} testing = {version = "0.14.0", path = "../../testing"} diff --git a/css/parser/src/lexer/mod.rs b/css/parser/src/lexer/mod.rs index 893c0af2bfd..65fb6f0f824 100644 --- a/css/parser/src/lexer/mod.rs +++ b/css/parser/src/lexer/mod.rs @@ -163,17 +163,61 @@ where try_delim!(b')', ")"); if self.input.is_byte(b'+') { - return self.read_plus(); + let pos = self.input.cur_pos(); + let c = self.input.cur().unwrap(); + + self.input.bump(); + + if self.would_start_number()? { + self.input.reset_to(pos); + + return self.read_number(); + } + + return Ok(Token::Delim { value: c }); } try_delim!(b',', ","); if self.input.is_byte(b'-') { - return self.read_minus(); + let pos = self.input.cur_pos(); + let c = self.input.cur().unwrap(); + + self.input.bump(); + + if self.would_start_number()? { + self.input.reset_to(pos); + + return self.read_number(); + } else if self.input.cur() == Some('-') && self.input.peek() == Some('>') { + self.input.bump(); + self.input.bump(); + + return Ok(Token::CDC); + } else if self.would_start_ident()? { + self.input.reset_to(pos); + + return self + .read_name() + .map(|(value, raw)| Token::Ident { value, raw }); + } + + return Ok(Token::Delim { value: c }); } if self.input.is_byte(b'.') { - return self.read_dot(); + let pos = self.input.cur_pos(); + let c = self.input.cur().unwrap(); + + self.input.bump(); + + if self.would_start_number()? { + self.input.reset_to(pos); + + return self.read_number(); + } + + return Ok(Token::Delim { value: c }); } try_delim!(b':', ":"); @@ -254,6 +298,47 @@ where return Ok(Token::Delim { value: c }); } + fn would_start_number(&mut self) -> LexResult { + let first = self.input.cur(); + + if first.is_none() { + return Ok(false); + } + + match first { + Some('+') | Some('-') => { + if let Some(second) = self.input.peek() { + return match second { + second if second.is_digit(10) => Ok(true), + '.' => { + if let Some(third) = self.input.peek_ahead() { + if third.is_digit(10) { + return Ok(true); + } + } + + Ok(false) + } + _ => Ok(false), + }; + } + + Ok(false) + } + Some('.') => { + if let Some(second) = self.input.peek() { + if second.is_digit(10) { + return Ok(true); + } + } + + Ok(false) + } + Some(first) if first.is_digit(10) => Ok(true), + _ => Ok(false), + } + } + fn is_valid_escape(&mut self) -> LexResult { if self.input.cur() != Some('\\') { return Ok(false); @@ -524,28 +609,6 @@ where Ok((c, raw)) } - fn read_dot(&mut self) -> LexResult { - if let Some(next) = self.input.peek() { - if next == '.' || next.is_digit(10) { - return self.read_number(); - } - } - - self.input.bump(); - Ok(tok!(".")) - } - - fn read_plus(&mut self) -> LexResult { - if let Some(next) = self.input.peek() { - if next == '.' || next.is_digit(10) { - return self.read_number(); - } - } - - self.input.bump(); - Ok(tok!("+")) - } - fn read_at_keyword(&mut self) -> LexResult { let name = self.read_name()?; @@ -555,32 +618,6 @@ where }) } - fn read_minus(&mut self) -> LexResult { - assert_eq!(self.input.cur(), Some('-')); - - match self.input.peek() { - Some('0'..='9') | Some('.') => return self.read_number(), - - _ => {} - } - - if self.input.peek() == Some('-') && self.input.peek_ahead() == Some('>') { - self.input.bump(); - self.input.bump(); - self.input.bump(); - return Ok(Token::CDC); - } - - if self.would_start_ident()? { - return self - .read_name() - .map(|(value, raw)| Token::Ident { value, raw }); - } - - self.input.bump(); - Ok(tok!("-")) - } - /// Ported from `wouldStartIdentifier` of `esbuild`. fn would_start_ident(&mut self) -> LexResult { match self.input.cur() { @@ -714,14 +751,6 @@ where } } -#[inline(always)] -fn is_digit(c: char) -> bool { - match c { - '0'..='9' => true, - _ => false, - } -} - #[inline(always)] fn is_uppercase_letter(c: char) -> bool { match c { @@ -759,7 +788,7 @@ pub(crate) fn is_name_start(c: char) -> bool { pub(crate) fn is_name_continue(c: char) -> bool { is_name_start(c) || match c { - c if is_digit(c) || c == '-' => true, + c if c.is_digit(10) || c == '-' => true, _ => false, } } diff --git a/css/parser/src/macros.rs b/css/parser/src/macros.rs index ed65a9a321d..a9735d864eb 100644 --- a/css/parser/src/macros.rs +++ b/css/parser/src/macros.rs @@ -60,10 +60,6 @@ macro_rules! tok { swc_css_ast::Token::Asterisk }; - (".") => { - swc_css_ast::Token::Dot - }; - ("#") => { swc_css_ast::Token::Hash }; @@ -105,11 +101,15 @@ macro_rules! tok { }; ("+") => { - swc_css_ast::Token::Plus + swc_css_ast::Token::Delim { value: '+', .. } }; ("-") => { - swc_css_ast::Token::Minus + swc_css_ast::Token::Delim { value: '-', .. } + }; + + (".") => { + swc_css_ast::Token::Delim { value: '.', .. } }; ("/") => { diff --git a/css/parser/src/parser/selector/mod.rs b/css/parser/src/parser/selector/mod.rs index 2129584467f..4ab1af20491 100644 --- a/css/parser/src/parser/selector/mod.rs +++ b/css/parser/src/parser/selector/mod.rs @@ -289,7 +289,6 @@ where fn parse_class_selector(&mut self) -> PResult { let start = self.input.cur_span()?.lo; - assert_eq!(*cur!(self), tok!(".")); bump!(self); let text = self.parse_selector_text()?; diff --git a/css/parser/tests/fixture/number/input.css b/css/parser/tests/fixture/number/input.css new file mode 100644 index 00000000000..3624b9359d3 --- /dev/null +++ b/css/parser/tests/fixture/number/input.css @@ -0,0 +1,10 @@ +div { + property: 10; + property: +10; + property: -10; + property: 0.1; + property: +0.1; + property: -0.1; + property: -.1; + property: +.1; +} diff --git a/css/parser/tests/fixture/number/output.json b/css/parser/tests/fixture/number/output.json new file mode 100644 index 00000000000..d5e2a643ff8 --- /dev/null +++ b/css/parser/tests/fixture/number/output.json @@ -0,0 +1,310 @@ +{ + "type": "Stylesheet", + "span": { + "start": 0, + "end": 161, + "ctxt": 0 + }, + "rules": [ + { + "type": "StyleRule", + "span": { + "start": 0, + "end": 160, + "ctxt": 0 + }, + "selectors": [ + { + "type": "ComplexSelector", + "span": { + "start": 0, + "end": 3, + "ctxt": 0 + }, + "selectors": [ + { + "type": "CompoundSelector", + "span": { + "start": 0, + "end": 3, + "ctxt": 0 + }, + "hasNestPrefix": false, + "combinator": null, + "typeSelector": { + "type": "NamespacedName", + "span": { + "start": 0, + "end": 3, + "ctxt": 0 + }, + "prefix": null, + "name": { + "type": "Text", + "span": { + "start": 0, + "end": 3, + "ctxt": 0 + }, + "value": "div", + "raw": "div" + } + }, + "subclassSelectors": [] + } + ] + } + ], + "block": { + "type": "DeclBlock", + "span": { + "start": 4, + "end": 160, + "ctxt": 0 + }, + "items": [ + { + "type": "Property", + "span": { + "start": 10, + "end": 22, + "ctxt": 0 + }, + "name": { + "type": "Text", + "span": { + "start": 10, + "end": 18, + "ctxt": 0 + }, + "value": "property", + "raw": "property" + }, + "values": [ + { + "type": "Number", + "span": { + "start": 20, + "end": 22, + "ctxt": 0 + }, + "value": 10.0 + } + ], + "important": null + }, + { + "type": "Property", + "span": { + "start": 28, + "end": 41, + "ctxt": 0 + }, + "name": { + "type": "Text", + "span": { + "start": 28, + "end": 36, + "ctxt": 0 + }, + "value": "property", + "raw": "property" + }, + "values": [ + { + "type": "Number", + "span": { + "start": 38, + "end": 41, + "ctxt": 0 + }, + "value": 10.0 + } + ], + "important": null + }, + { + "type": "Property", + "span": { + "start": 47, + "end": 60, + "ctxt": 0 + }, + "name": { + "type": "Text", + "span": { + "start": 47, + "end": 55, + "ctxt": 0 + }, + "value": "property", + "raw": "property" + }, + "values": [ + { + "type": "Number", + "span": { + "start": 57, + "end": 60, + "ctxt": 0 + }, + "value": -10.0 + } + ], + "important": null + }, + { + "type": "Property", + "span": { + "start": 66, + "end": 79, + "ctxt": 0 + }, + "name": { + "type": "Text", + "span": { + "start": 66, + "end": 74, + "ctxt": 0 + }, + "value": "property", + "raw": "property" + }, + "values": [ + { + "type": "Number", + "span": { + "start": 76, + "end": 79, + "ctxt": 0 + }, + "value": 0.1 + } + ], + "important": null + }, + { + "type": "Property", + "span": { + "start": 85, + "end": 99, + "ctxt": 0 + }, + "name": { + "type": "Text", + "span": { + "start": 85, + "end": 93, + "ctxt": 0 + }, + "value": "property", + "raw": "property" + }, + "values": [ + { + "type": "Number", + "span": { + "start": 95, + "end": 99, + "ctxt": 0 + }, + "value": 0.1 + } + ], + "important": null + }, + { + "type": "Property", + "span": { + "start": 105, + "end": 119, + "ctxt": 0 + }, + "name": { + "type": "Text", + "span": { + "start": 105, + "end": 113, + "ctxt": 0 + }, + "value": "property", + "raw": "property" + }, + "values": [ + { + "type": "Number", + "span": { + "start": 115, + "end": 119, + "ctxt": 0 + }, + "value": -0.1 + } + ], + "important": null + }, + { + "type": "Property", + "span": { + "start": 125, + "end": 138, + "ctxt": 0 + }, + "name": { + "type": "Text", + "span": { + "start": 125, + "end": 133, + "ctxt": 0 + }, + "value": "property", + "raw": "property" + }, + "values": [ + { + "type": "Number", + "span": { + "start": 135, + "end": 138, + "ctxt": 0 + }, + "value": -0.1 + } + ], + "important": null + }, + { + "type": "Property", + "span": { + "start": 144, + "end": 157, + "ctxt": 0 + }, + "name": { + "type": "Text", + "span": { + "start": 144, + "end": 152, + "ctxt": 0 + }, + "value": "property", + "raw": "property" + }, + "values": [ + { + "type": "Number", + "span": { + "start": 154, + "end": 157, + "ctxt": 0 + }, + "value": 0.1 + } + ], + "important": null + } + ] + } + } + ] +} diff --git a/css/parser/tests/fixture/number/span.rust-debug b/css/parser/tests/fixture/number/span.rust-debug new file mode 100644 index 00000000000..5a9071f1980 --- /dev/null +++ b/css/parser/tests/fixture/number/span.rust-debug @@ -0,0 +1,265 @@ +error: Stylesheet + --> $DIR/tests/fixture/number/input.css:1:1 + | +1 | / div { +2 | | property: 10; +3 | | property: +10; +4 | | property: -10; +... | +9 | | property: +.1; +10 | | } + | |__^ + +error: Rule + --> $DIR/tests/fixture/number/input.css:1:1 + | +1 | / div { +2 | | property: 10; +3 | | property: +10; +4 | | property: -10; +... | +9 | | property: +.1; +10 | | } + | |_^ + +error: StyleRule + --> $DIR/tests/fixture/number/input.css:1:1 + | +1 | / div { +2 | | property: 10; +3 | | property: +10; +4 | | property: -10; +... | +9 | | property: +.1; +10 | | } + | |_^ + +error: ComplexSelector + --> $DIR/tests/fixture/number/input.css:1:1 + | +1 | div { + | ^^^ + +error: CompoundSelector + --> $DIR/tests/fixture/number/input.css:1:1 + | +1 | div { + | ^^^ + +error: NamespacedName + --> $DIR/tests/fixture/number/input.css:1:1 + | +1 | div { + | ^^^ + +error: Text + --> $DIR/tests/fixture/number/input.css:1:1 + | +1 | div { + | ^^^ + +error: DeclBlock + --> $DIR/tests/fixture/number/input.css:1:5 + | +1 | div { + | _____^ +2 | | property: 10; +3 | | property: +10; +4 | | property: -10; +... | +9 | | property: +.1; +10 | | } + | |_^ + +error: Property + --> $DIR/tests/fixture/number/input.css:2:5 + | +2 | property: 10; + | ^^^^^^^^^^^^ + +error: Text + --> $DIR/tests/fixture/number/input.css:2:5 + | +2 | property: 10; + | ^^^^^^^^ + +error: Value + --> $DIR/tests/fixture/number/input.css:2:15 + | +2 | property: 10; + | ^^ + +error: Num + --> $DIR/tests/fixture/number/input.css:2:15 + | +2 | property: 10; + | ^^ + +error: Property + --> $DIR/tests/fixture/number/input.css:3:5 + | +3 | property: +10; + | ^^^^^^^^^^^^^ + +error: Text + --> $DIR/tests/fixture/number/input.css:3:5 + | +3 | property: +10; + | ^^^^^^^^ + +error: Value + --> $DIR/tests/fixture/number/input.css:3:15 + | +3 | property: +10; + | ^^^ + +error: Num + --> $DIR/tests/fixture/number/input.css:3:15 + | +3 | property: +10; + | ^^^ + +error: Property + --> $DIR/tests/fixture/number/input.css:4:5 + | +4 | property: -10; + | ^^^^^^^^^^^^^ + +error: Text + --> $DIR/tests/fixture/number/input.css:4:5 + | +4 | property: -10; + | ^^^^^^^^ + +error: Value + --> $DIR/tests/fixture/number/input.css:4:15 + | +4 | property: -10; + | ^^^ + +error: Num + --> $DIR/tests/fixture/number/input.css:4:15 + | +4 | property: -10; + | ^^^ + +error: Property + --> $DIR/tests/fixture/number/input.css:5:5 + | +5 | property: 0.1; + | ^^^^^^^^^^^^^ + +error: Text + --> $DIR/tests/fixture/number/input.css:5:5 + | +5 | property: 0.1; + | ^^^^^^^^ + +error: Value + --> $DIR/tests/fixture/number/input.css:5:15 + | +5 | property: 0.1; + | ^^^ + +error: Num + --> $DIR/tests/fixture/number/input.css:5:15 + | +5 | property: 0.1; + | ^^^ + +error: Property + --> $DIR/tests/fixture/number/input.css:6:5 + | +6 | property: +0.1; + | ^^^^^^^^^^^^^^ + +error: Text + --> $DIR/tests/fixture/number/input.css:6:5 + | +6 | property: +0.1; + | ^^^^^^^^ + +error: Value + --> $DIR/tests/fixture/number/input.css:6:15 + | +6 | property: +0.1; + | ^^^^ + +error: Num + --> $DIR/tests/fixture/number/input.css:6:15 + | +6 | property: +0.1; + | ^^^^ + +error: Property + --> $DIR/tests/fixture/number/input.css:7:5 + | +7 | property: -0.1; + | ^^^^^^^^^^^^^^ + +error: Text + --> $DIR/tests/fixture/number/input.css:7:5 + | +7 | property: -0.1; + | ^^^^^^^^ + +error: Value + --> $DIR/tests/fixture/number/input.css:7:15 + | +7 | property: -0.1; + | ^^^^ + +error: Num + --> $DIR/tests/fixture/number/input.css:7:15 + | +7 | property: -0.1; + | ^^^^ + +error: Property + --> $DIR/tests/fixture/number/input.css:8:5 + | +8 | property: -.1; + | ^^^^^^^^^^^^^ + +error: Text + --> $DIR/tests/fixture/number/input.css:8:5 + | +8 | property: -.1; + | ^^^^^^^^ + +error: Value + --> $DIR/tests/fixture/number/input.css:8:15 + | +8 | property: -.1; + | ^^^ + +error: Num + --> $DIR/tests/fixture/number/input.css:8:15 + | +8 | property: -.1; + | ^^^ + +error: Property + --> $DIR/tests/fixture/number/input.css:9:5 + | +9 | property: +.1; + | ^^^^^^^^^^^^^ + +error: Text + --> $DIR/tests/fixture/number/input.css:9:5 + | +9 | property: +.1; + | ^^^^^^^^ + +error: Value + --> $DIR/tests/fixture/number/input.css:9:15 + | +9 | property: +.1; + | ^^^ + +error: Num + --> $DIR/tests/fixture/number/input.css:9:15 + | +9 | property: +.1; + | ^^^ + diff --git a/css/parser/tests/fixture/styled-jsx/selector/1/output.json b/css/parser/tests/fixture/styled-jsx/selector/1/output.json index 3526bde52db..1617fa2a93a 100644 --- a/css/parser/tests/fixture/styled-jsx/selector/1/output.json +++ b/css/parser/tests/fixture/styled-jsx/selector/1/output.json @@ -65,7 +65,11 @@ "end": 9, "ctxt": 0 }, - "token": "Dot" + "token": { + "Delim": { + "value": "." + } + } }, { "span": { @@ -94,7 +98,11 @@ "end": 14, "ctxt": 0 }, - "token": "Plus" + "token": { + "Delim": { + "value": "+" + } + } }, { "span": { diff --git a/css/parser/tests/fixture/styled-jsx/selector/1/span.rust-debug b/css/parser/tests/fixture/styled-jsx/selector/1/span.rust-debug index 97949810757..5e331f48aec 100644 --- a/css/parser/tests/fixture/styled-jsx/selector/1/span.rust-debug +++ b/css/parser/tests/fixture/styled-jsx/selector/1/span.rust-debug @@ -58,7 +58,7 @@ error: Tokens 1 | :global(.foo + a) { | ^^^^^^^^ -error: Dot +error: Delim { value: '.' } --> $DIR/tests/fixture/styled-jsx/selector/1/input.css:1:9 | 1 | :global(.foo + a) { @@ -76,7 +76,7 @@ error: WhiteSpace 1 | :global(.foo + a) { | ^ -error: Plus +error: Delim { value: '+' } --> $DIR/tests/fixture/styled-jsx/selector/1/input.css:1:14 | 1 | :global(.foo + a) { diff --git a/css/parser/tests/fixture/styled-jsx/selector/2/output.json b/css/parser/tests/fixture/styled-jsx/selector/2/output.json index 2ff73d8a70b..a118886e8cd 100644 --- a/css/parser/tests/fixture/styled-jsx/selector/2/output.json +++ b/css/parser/tests/fixture/styled-jsx/selector/2/output.json @@ -137,7 +137,11 @@ "end": 20, "ctxt": 0 }, - "token": "Dot" + "token": { + "Delim": { + "value": "." + } + } }, { "span": { diff --git a/css/parser/tests/fixture/styled-jsx/selector/2/span.rust-debug b/css/parser/tests/fixture/styled-jsx/selector/2/span.rust-debug index 706fd5340d8..cd2af2d8374 100644 --- a/css/parser/tests/fixture/styled-jsx/selector/2/span.rust-debug +++ b/css/parser/tests/fixture/styled-jsx/selector/2/span.rust-debug @@ -100,7 +100,7 @@ error: LParen 1 | p :global(span:not(.test)) { | ^ -error: Dot +error: Delim { value: '.' } --> $DIR/tests/fixture/styled-jsx/selector/2/input.css:1:20 | 1 | p :global(span:not(.test)) { diff --git a/css/parser/tests/recovery/delim-token/minus/input.css b/css/parser/tests/recovery/delim-token/minus/input.css new file mode 100644 index 00000000000..8632243dd79 --- /dev/null +++ b/css/parser/tests/recovery/delim-token/minus/input.css @@ -0,0 +1,3 @@ +a { + prop: -; +} diff --git a/css/parser/tests/recovery/delim-token/minus/output.json b/css/parser/tests/recovery/delim-token/minus/output.json new file mode 100644 index 00000000000..30e812506f7 --- /dev/null +++ b/css/parser/tests/recovery/delim-token/minus/output.json @@ -0,0 +1,121 @@ +{ + "type": "Stylesheet", + "span": { + "start": 0, + "end": 19, + "ctxt": 0 + }, + "rules": [ + { + "type": "StyleRule", + "span": { + "start": 0, + "end": 18, + "ctxt": 0 + }, + "selectors": [ + { + "type": "ComplexSelector", + "span": { + "start": 0, + "end": 1, + "ctxt": 0 + }, + "selectors": [ + { + "type": "CompoundSelector", + "span": { + "start": 0, + "end": 1, + "ctxt": 0 + }, + "hasNestPrefix": false, + "combinator": null, + "typeSelector": { + "type": "NamespacedName", + "span": { + "start": 0, + "end": 1, + "ctxt": 0 + }, + "prefix": null, + "name": { + "type": "Text", + "span": { + "start": 0, + "end": 1, + "ctxt": 0 + }, + "value": "a", + "raw": "a" + } + }, + "subclassSelectors": [] + } + ] + } + ], + "block": { + "type": "DeclBlock", + "span": { + "start": 2, + "end": 18, + "ctxt": 0 + }, + "items": [ + { + "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" + }, + { + "span": { + "start": 14, + "end": 15, + "ctxt": 0 + }, + "token": { + "Delim": { + "value": "-" + } + } + } + ] + } + ] + } + } + ] +} diff --git a/css/parser/tests/recovery/delim-token/minus/output.swc-stderr b/css/parser/tests/recovery/delim-token/minus/output.swc-stderr new file mode 100644 index 00000000000..e4dc2c3d889 --- /dev/null +++ b/css/parser/tests/recovery/delim-token/minus/output.swc-stderr @@ -0,0 +1,6 @@ +error: Expected Property value + --> $DIR/tests/recovery/delim-token/minus/input.css:2:11 + | +2 | prop: -; + | ^ + diff --git a/css/parser/tests/recovery/delim-token/plus/input.css b/css/parser/tests/recovery/delim-token/plus/input.css new file mode 100644 index 00000000000..703d8244cef --- /dev/null +++ b/css/parser/tests/recovery/delim-token/plus/input.css @@ -0,0 +1,3 @@ +a { + prop: +; +} diff --git a/css/parser/tests/recovery/delim-token/plus/output.json b/css/parser/tests/recovery/delim-token/plus/output.json new file mode 100644 index 00000000000..438ac4d4a7d --- /dev/null +++ b/css/parser/tests/recovery/delim-token/plus/output.json @@ -0,0 +1,121 @@ +{ + "type": "Stylesheet", + "span": { + "start": 0, + "end": 19, + "ctxt": 0 + }, + "rules": [ + { + "type": "StyleRule", + "span": { + "start": 0, + "end": 18, + "ctxt": 0 + }, + "selectors": [ + { + "type": "ComplexSelector", + "span": { + "start": 0, + "end": 1, + "ctxt": 0 + }, + "selectors": [ + { + "type": "CompoundSelector", + "span": { + "start": 0, + "end": 1, + "ctxt": 0 + }, + "hasNestPrefix": false, + "combinator": null, + "typeSelector": { + "type": "NamespacedName", + "span": { + "start": 0, + "end": 1, + "ctxt": 0 + }, + "prefix": null, + "name": { + "type": "Text", + "span": { + "start": 0, + "end": 1, + "ctxt": 0 + }, + "value": "a", + "raw": "a" + } + }, + "subclassSelectors": [] + } + ] + } + ], + "block": { + "type": "DeclBlock", + "span": { + "start": 2, + "end": 18, + "ctxt": 0 + }, + "items": [ + { + "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" + }, + { + "span": { + "start": 14, + "end": 15, + "ctxt": 0 + }, + "token": { + "Delim": { + "value": "+" + } + } + } + ] + } + ] + } + } + ] +} diff --git a/css/parser/tests/recovery/delim-token/plus/output.swc-stderr b/css/parser/tests/recovery/delim-token/plus/output.swc-stderr new file mode 100644 index 00000000000..90dd56a68f0 --- /dev/null +++ b/css/parser/tests/recovery/delim-token/plus/output.swc-stderr @@ -0,0 +1,6 @@ +error: Expected Property value + --> $DIR/tests/recovery/delim-token/plus/input.css:2:11 + | +2 | prop: +; + | ^ + diff --git a/css/parser/tests/recovery/styled-jsx/1/output.json b/css/parser/tests/recovery/styled-jsx/1/output.json index 6833a19d513..50947f301d2 100644 --- a/css/parser/tests/recovery/styled-jsx/1/output.json +++ b/css/parser/tests/recovery/styled-jsx/1/output.json @@ -266,7 +266,11 @@ "end": 138, "ctxt": 0 }, - "token": "Dot" + "token": { + "Delim": { + "value": "." + } + } }, { "span": { @@ -575,7 +579,11 @@ "end": 335, "ctxt": 0 }, - "token": "Dot" + "token": { + "Delim": { + "value": "." + } + } }, { "span": { @@ -795,7 +803,11 @@ "end": 464, "ctxt": 0 }, - "token": "Dot" + "token": { + "Delim": { + "value": "." + } + } }, { "span": { diff --git a/css/parser/tests/recovery/styled-jsx/2/output.json b/css/parser/tests/recovery/styled-jsx/2/output.json index a8096d5a7fa..6123dda1bc3 100644 --- a/css/parser/tests/recovery/styled-jsx/2/output.json +++ b/css/parser/tests/recovery/styled-jsx/2/output.json @@ -112,7 +112,11 @@ "end": 14, "ctxt": 0 }, - "token": "Dot" + "token": { + "Delim": { + "value": "." + } + } }, { "span": { diff --git a/css/stylis/Cargo.toml b/css/stylis/Cargo.toml index 15b9d41ca13..7fd33e6e326 100644 --- a/css/stylis/Cargo.toml +++ b/css/stylis/Cargo.toml @@ -6,18 +6,18 @@ edition = "2018" license = "Apache-2.0/MIT" name = "swc_stylis" repository = "https://github.com/swc-project/swc.git" -version = "0.11.0" +version = "0.12.0" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html [dependencies] swc_atoms = {version = "0.2.7", path = "../../atoms"} swc_common = {version = "0.13.0", path = "../../common"} -swc_css_ast = {version = "0.13.0", path = "../ast"} -swc_css_utils = {version = "0.10.0", path = "../utils/"} -swc_css_visit = {version = "0.12.0", path = "../visit"} +swc_css_ast = {version = "0.14.0", path = "../ast"} +swc_css_utils = {version = "0.11.0", path = "../utils/"} +swc_css_visit = {version = "0.13.0", path = "../visit"} [dev-dependencies] -swc_css_codegen = {version = "0.12.0", path = "../codegen"} -swc_css_parser = {version = "0.14.0", path = "../parser"} +swc_css_codegen = {version = "0.13.0", path = "../codegen"} +swc_css_parser = {version = "0.15.0", path = "../parser"} testing = {version = "0.14.0", path = "../../testing"} diff --git a/css/utils/Cargo.toml b/css/utils/Cargo.toml index 5be4333f729..591df750110 100644 --- a/css/utils/Cargo.toml +++ b/css/utils/Cargo.toml @@ -6,11 +6,11 @@ edition = "2018" license = "Apache-2.0/MIT" name = "swc_css_utils" repository = "https://github.com/swc-project/swc.git" -version = "0.10.0" +version = "0.11.0" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html [dependencies] swc_atoms = {version = "0.2.7", path = "../../atoms"} swc_common = {version = "0.13.0", path = "../../common"} -swc_css_ast = {version = "0.13.0", path = "../ast"} -swc_css_visit = {version = "0.12.0", path = "../visit"} +swc_css_ast = {version = "0.14.0", path = "../ast"} +swc_css_visit = {version = "0.13.0", path = "../visit"} diff --git a/css/visit/Cargo.toml b/css/visit/Cargo.toml index db10e705a35..08488d3f34b 100644 --- a/css/visit/Cargo.toml +++ b/css/visit/Cargo.toml @@ -6,12 +6,12 @@ edition = "2018" license = "Apache-2.0/MIT" name = "swc_css_visit" repository = "https://github.com/swc-project/swc.git" -version = "0.12.0" +version = "0.13.0" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html [dependencies] swc_atoms = {version = "0.2.7", path = "../../atoms"} swc_common = {version = "0.13.0", path = "../../common"} -swc_css_ast = {version = "0.13.0", path = "../ast/"} +swc_css_ast = {version = "0.14.0", path = "../ast/"} swc_visit = {version = "0.2.6", path = "../../visit"}