From bea6cce0c6442891e6cfe3df5982c13ea3dda5a3 Mon Sep 17 00:00:00 2001 From: Alexander Akait <4567934+alexander-akait@users.noreply.github.com> Date: Thu, 10 Nov 2022 04:36:53 +0300 Subject: [PATCH] perf(css): Reduce size of tokens (#6384) --- crates/swc_css_ast/src/token.rs | 22 +-- crates/swc_css_ast/src/value.rs | 4 - crates/swc_css_codegen/src/lib.rs | 20 +-- crates/swc_css_codegen/tests/fixture.rs | 2 - crates/swc_css_minifier/src/compressor/mod.rs | 4 +- crates/swc_css_minifier/src/compressor/url.rs | 2 - crates/swc_css_parser/src/lexer/mod.rs | 48 +++--- .../src/parser/values_and_units/mod.rs | 4 - .../fixture/at-rule/document/output.json | 4 +- .../tests/fixture/at-rule/import/output.json | 144 +++++------------- .../fixture/at-rule/namespace/output.json | 8 +- .../tests/fixture/csstree/1/output.json | 4 +- .../tests/fixture/declaration/output.json | 8 +- .../misc/8Gs_Q4kYqijbgIQ6xIW8qw/output.json | 4 +- .../misc/FU0reCXb694XEXwdM2wqsQ/output.json | 4 +- .../misc/Uuvi9sS4YR_ILpKl0xpfOg/output.json | 4 +- .../misc/dCIAD8Ab98J4V9rGaJvZlw/output.json | 4 +- .../misc/eqYc139qNzkqXqBaJaQm6A/output.json | 4 +- .../misc/fmt94qCRfRXbpej5kzLZUw/output.json | 4 +- .../misc/gPpnAqOuxEdLAEJjFaUEkg/output.json | 4 +- .../misc/i3YGyP16CjaKe5cnWygVeQ/output.json | 4 +- .../misc/mx296i8q4HfA0IzZ055Xpw/output.json | 4 +- .../tests/fixture/function/url/output.json | 60 ++------ .../tests/fixture/hex-colors/input.css | 1 + .../tests/fixture/hex-colors/output.json | 37 ++++- .../tests/fixture/hex-colors/span.rust-debug | 60 +++++++- .../selector/pseudo-class/unknown/output.json | 2 - .../pseudo-class/unknown/span.rust-debug | 3 +- .../pseudo-element/unknown/output.json | 2 - .../pseudo-element/unknown/span.rust-debug | 3 +- .../tests/fixture/stylis/comma/01/output.json | 4 +- .../tests/fixture/value/escaped/output.json | 8 +- .../tests/fixture/value/url/output.json | 44 ++---- .../bad-url-token/double-quotes/output.json | 1 - .../double-quotes/span.rust-debug | 2 +- .../bad-url-token/invalid-escape/output.json | 1 - .../invalid-escape/span.rust-debug | 3 +- .../left-parenthesis/output.json | 1 - .../left-parenthesis/span.rust-debug | 2 +- .../bad-url-token/single-quotes/output.json | 1 - .../single-quotes/span.rust-debug | 2 +- .../whitespace-in-middle/output.json | 1 - .../whitespace-in-middle/span.rust-debug | 2 +- .../bad-url-token/whitespace/output.json | 1 - .../bad-url-token/whitespace/span.rust-debug | 3 +- .../function/bad-comment-2/output.json | 1 - .../function/bad-comment-2/span.rust-debug | 5 +- .../recovery/function/bad-comment/output.json | 1 - .../function/bad-comment/span.rust-debug | 5 +- .../tests/recovery/value/quotes/output.json | 6 +- .../recovery/value/quotes/span.rust-debug | 4 +- .../recovery/value/string/newline/output.json | 3 +- .../value/string/newline/span.rust-debug | 2 +- .../recovery/value/url/basic/output.json | 22 +-- .../recovery/value/url/basic/span.rust-debug | 4 +- .../tests/recovery/value/url/eof/output.json | 4 +- .../value/url/parenthesis/output.json | 1 - .../value/url/parenthesis/span.rust-debug | 3 +- crates/swc_css_visit/src/lib.rs | 2 - 59 files changed, 231 insertions(+), 386 deletions(-) diff --git a/crates/swc_css_ast/src/token.rs b/crates/swc_css_ast/src/token.rs index d705bd095f3..0471126b6be 100644 --- a/crates/swc_css_ast/src/token.rs +++ b/crates/swc_css_ast/src/token.rs @@ -89,9 +89,7 @@ pub enum Token { BadString { #[cfg_attr(feature = "rkyv", with(swc_atoms::EncodeJsWord))] - value: JsWord, - #[cfg_attr(feature = "rkyv", with(swc_atoms::EncodeJsWord))] - raw: JsWord, + raw_value: JsWord, }, /// `url(value)` @@ -101,10 +99,6 @@ pub enum Token { #[cfg_attr(feature = "rkyv", with(swc_atoms::EncodeJsWord))] raw_name: JsWord, #[cfg_attr(feature = "rkyv", with(swc_atoms::EncodeJsWord))] - before: JsWord, - #[cfg_attr(feature = "rkyv", with(swc_atoms::EncodeJsWord))] - after: JsWord, - #[cfg_attr(feature = "rkyv", with(swc_atoms::EncodeJsWord))] value: JsWord, #[cfg_attr(feature = "rkyv", with(swc_atoms::EncodeJsWord))] raw_value: JsWord, @@ -116,8 +110,6 @@ pub enum Token { #[cfg_attr(feature = "rkyv", with(swc_atoms::EncodeJsWord))] raw_name: JsWord, #[cfg_attr(feature = "rkyv", with(swc_atoms::EncodeJsWord))] - value: JsWord, - #[cfg_attr(feature = "rkyv", with(swc_atoms::EncodeJsWord))] raw_value: JsWord, }, @@ -213,11 +205,13 @@ impl Hash for Token { Token::Ident { value, raw } | Token::Function { value, raw } | Token::AtKeyword { value, raw } - | Token::String { value, raw } - | Token::BadString { value, raw } => { + | Token::String { value, raw } => { value.hash(state); raw.hash(state); } + Token::BadString { raw_value } => { + raw_value.hash(state); + } Token::Hash { value, raw, is_id } => { value.hash(state); raw.hash(state); @@ -226,27 +220,21 @@ impl Hash for Token { Token::Url { name, raw_name, - before, - after, value, raw_value, } => { name.hash(state); raw_name.hash(state); - before.hash(state); - after.hash(state); value.hash(state); raw_value.hash(state); } Token::BadUrl { name, raw_name, - value, raw_value, } => { name.hash(state); raw_name.hash(state); - value.hash(state); raw_value.hash(state); } Token::Delim { value } => { diff --git a/crates/swc_css_ast/src/value.rs b/crates/swc_css_ast/src/value.rs index 0481d480dd0..09c51d0dc63 100644 --- a/crates/swc_css_ast/src/value.rs +++ b/crates/swc_css_ast/src/value.rs @@ -432,11 +432,7 @@ pub struct UrlValueRaw { #[cfg_attr(feature = "rkyv", with(swc_atoms::EncodeJsWord))] pub value: JsWord, #[cfg_attr(feature = "rkyv", with(swc_atoms::EncodeJsWord))] - pub before: Option, - #[cfg_attr(feature = "rkyv", with(swc_atoms::EncodeJsWord))] pub raw: Option, - #[cfg_attr(feature = "rkyv", with(swc_atoms::EncodeJsWord))] - pub after: Option, } #[ast_node] diff --git a/crates/swc_css_codegen/src/lib.rs b/crates/swc_css_codegen/src/lib.rs index 4335329be36..4f597c54922 100644 --- a/crates/swc_css_codegen/src/lib.rs +++ b/crates/swc_css_codegen/src/lib.rs @@ -1978,8 +1978,8 @@ where write_raw!(self, span, &function); } - Token::BadString { raw, .. } => { - write_str!(self, span, raw); + Token::BadString { raw_value } => { + write_str!(self, span, raw_value); } Token::String { raw, .. } => { write_str!(self, span, raw); @@ -1987,19 +1987,13 @@ where Token::Url { raw_name, raw_value, - before, - after, .. } => { - let mut url = String::with_capacity( - raw_name.len() + before.len() + raw_value.len() + after.len() + 2, - ); + let mut url = String::with_capacity(raw_name.len() + raw_value.len() + 2); url.push_str(raw_name); url.push('('); - url.push_str(before); url.push_str(raw_value); - url.push_str(after); url.push(')'); write_str!(self, span, &url); @@ -2009,7 +2003,7 @@ where raw_value, .. } => { - let mut bad_url = String::with_capacity(raw_name.len() + raw_value.len() + 2); + let mut bad_url = String::with_capacity(raw_value.len() + 2); bad_url.push_str(raw_name); bad_url.push('('); @@ -2097,12 +2091,10 @@ where url.push_str(&n.value); write_str!(self, n.span, &url); - } else if let (Some(before), Some(raw), Some(after)) = (&n.before, &n.raw, &n.after) { - let mut url = String::with_capacity(before.len() + raw.len() + after.len()); + } else if let Some(raw) = &n.raw { + let mut url = String::with_capacity(raw.len()); - url.push_str(before); url.push_str(raw); - url.push_str(after); write_str!(self, n.span, &url); } else { diff --git a/crates/swc_css_codegen/tests/fixture.rs b/crates/swc_css_codegen/tests/fixture.rs index 55ac18780e2..c0fa305aa55 100644 --- a/crates/swc_css_codegen/tests/fixture.rs +++ b/crates/swc_css_codegen/tests/fixture.rs @@ -283,8 +283,6 @@ impl VisitMut for NormalizeTest { fn visit_mut_url_value_raw(&mut self, n: &mut UrlValueRaw) { n.visit_mut_children_with(self); - n.before = None; - n.after = None; n.raw = None; } diff --git a/crates/swc_css_minifier/src/compressor/mod.rs b/crates/swc_css_minifier/src/compressor/mod.rs index ab0c04e858f..240d3e0ab53 100644 --- a/crates/swc_css_minifier/src/compressor/mod.rs +++ b/crates/swc_css_minifier/src/compressor/mod.rs @@ -400,7 +400,9 @@ impl VisitMut for Compressor { | Token::Function { value, .. } | Token::AtKeyword { value, .. } | Token::String { value, .. } - | Token::BadString { value, .. } + | Token::BadString { + raw_value: value, .. + } | Token::Dimension { unit: value, .. } if !contains_only_ascii_characters(value) => { diff --git a/crates/swc_css_minifier/src/compressor/url.rs b/crates/swc_css_minifier/src/compressor/url.rs index 6d80b33938b..bda458d731b 100644 --- a/crates/swc_css_minifier/src/compressor/url.rs +++ b/crates/swc_css_minifier/src/compressor/url.rs @@ -46,9 +46,7 @@ impl Compressor { url.value = Some(Box::new(UrlValue::Raw(UrlValueRaw { span: *span, value: escaped.into(), - before: None, raw: None, - after: None, }))); } } diff --git a/crates/swc_css_parser/src/lexer/mod.rs b/crates/swc_css_parser/src/lexer/mod.rs index 104aaaf7884..7574eed9771 100644 --- a/crates/swc_css_parser/src/lexer/mod.rs +++ b/crates/swc_css_parser/src/lexer/mod.rs @@ -730,8 +730,7 @@ where l.reconsume(); return Ok(Token::BadString { - value: (&**buf).into(), - raw: (&**raw).into(), + raw_value: (&**raw).into(), }); } @@ -780,15 +779,17 @@ where // This section describes how to consume a url token from a stream of code // points. It returns either a or a . - fn read_url(&mut self, name: (JsWord, JsWord), mut before: String) -> LexResult { + fn read_url(&mut self, name: (JsWord, JsWord), before: String) -> LexResult { // Initially create a with its value set to the empty string. self.with_buf_and_raw_buf(|l, out, raw| { + raw.push_str(&before); + // Consume as much whitespace as possible. while let Some(c) = l.next() { if is_whitespace(c) { l.consume(); - before.push(c); + raw.push(c); } else { break; } @@ -807,8 +808,6 @@ where raw_name: name.1, value: (&**out).into(), raw_value: (&**raw).into(), - before: before.into(), - after: js_word!(""), }); } @@ -822,8 +821,6 @@ where raw_name: name.1, value: (&**out).into(), raw_value: (&**raw).into(), - before: before.into(), - after: js_word!(""), }); } @@ -853,25 +850,25 @@ where Some(')') => { l.consume(); - return Ok(Token::Url { - name: name.0, - raw_name: name.1, - value: (&**out).into(), - raw_value: (&**raw).into(), - before: before.into(), - after: whitespaces.into(), - }); - } - None => { - l.emit_error(ErrorKind::UnterminatedUrl); + raw.push_str(&whitespaces); + + return Ok(Token::Url { + name: name.0, + raw_name: name.1, + value: (&**out).into(), + raw_value: (&**raw).into(), + }); + } + None => { + l.emit_error(ErrorKind::UnterminatedUrl); + + raw.push_str(&whitespaces); return Ok(Token::Url { name: name.0, raw_name: name.1, value: (&**out).into(), raw_value: (&**raw).into(), - before: before.into(), - after: whitespaces.into(), }); } _ => {} @@ -890,8 +887,7 @@ where return Ok(Token::BadUrl { name: name.0, raw_name: name.1, - value: (before.clone() + (&**raw)).into(), - raw_value: (before.clone() + (&**raw)).into(), + raw_value: (&**raw).into(), }); } @@ -914,8 +910,7 @@ where return Ok(Token::BadUrl { name: name.0, raw_name: name.1, - value: (before.clone() + (&**raw)).into(), - raw_value: (before.clone() + (&**raw)).into(), + raw_value: (&**raw).into(), }); } @@ -946,8 +941,7 @@ where return Ok(Token::BadUrl { name: name.0, raw_name: name.1, - value: (before.clone() + (&**raw)).into(), - raw_value: (before.clone() + (&**raw)).into(), + raw_value: (&**raw).into(), }); } } diff --git a/crates/swc_css_parser/src/parser/values_and_units/mod.rs b/crates/swc_css_parser/src/parser/values_and_units/mod.rs index 72d793f060b..25189aa70fb 100644 --- a/crates/swc_css_parser/src/parser/values_and_units/mod.rs +++ b/crates/swc_css_parser/src/parser/values_and_units/mod.rs @@ -2870,8 +2870,6 @@ where raw_name, value, raw_value, - before, - after, } => { let name_length = raw_name.len() as u32; let name = Ident { @@ -2890,9 +2888,7 @@ where Default::default(), ), value, - before: Some(before), raw: Some(raw_value), - after: Some(after), }))); Ok(Url { diff --git a/crates/swc_css_parser/tests/fixture/at-rule/document/output.json b/crates/swc_css_parser/tests/fixture/at-rule/document/output.json index df96422107e..865bbe4f5d8 100644 --- a/crates/swc_css_parser/tests/fixture/at-rule/document/output.json +++ b/crates/swc_css_parser/tests/fixture/at-rule/document/output.json @@ -589,9 +589,7 @@ "ctxt": 0 }, "value": "https://www.example.com/", - "before": "", - "raw": "https://www.example.com/", - "after": "" + "raw": "https://www.example.com/" }, "modifiers": null } diff --git a/crates/swc_css_parser/tests/fixture/at-rule/import/output.json b/crates/swc_css_parser/tests/fixture/at-rule/import/output.json index 8b1b97da004..3324fd420b2 100644 --- a/crates/swc_css_parser/tests/fixture/at-rule/import/output.json +++ b/crates/swc_css_parser/tests/fixture/at-rule/import/output.json @@ -171,9 +171,7 @@ "ctxt": 0 }, "value": "./style.css", - "before": "", - "raw": "./style.css", - "after": "" + "raw": "./style.css" }, "modifiers": null }, @@ -367,9 +365,7 @@ "ctxt": 0 }, "value": "./style.css", - "before": "", - "raw": "./style.css", - "after": "" + "raw": "./style.css" }, "modifiers": null }, @@ -1881,9 +1877,7 @@ "ctxt": 0 }, "value": "test.css", - "before": "", - "raw": "test.css", - "after": "" + "raw": "test.css" }, "modifiers": null }, @@ -2057,9 +2051,7 @@ "ctxt": 0 }, "value": "test.css", - "before": "", - "raw": "test.css", - "after": "" + "raw": "test.css" }, "modifiers": null }, @@ -2117,9 +2109,7 @@ "ctxt": 0 }, "value": "test.css", - "before": "", - "raw": "test.css", - "after": "" + "raw": "test.css" }, "modifiers": null }, @@ -2177,9 +2167,7 @@ "ctxt": 0 }, "value": "test.css", - "before": "", - "raw": "test.css", - "after": " " + "raw": "test.css " }, "modifiers": null }, @@ -2237,9 +2225,7 @@ "ctxt": 0 }, "value": "test.css", - "before": " ", - "raw": "test.css", - "after": "" + "raw": " test.css" }, "modifiers": null }, @@ -2297,9 +2283,7 @@ "ctxt": 0 }, "value": "test.css", - "before": " ", - "raw": "test.css", - "after": " " + "raw": " test.css " }, "modifiers": null }, @@ -2357,9 +2341,7 @@ "ctxt": 0 }, "value": "test.css", - "before": "\n", - "raw": "test.css", - "after": "\n" + "raw": "\ntest.css\n" }, "modifiers": null }, @@ -2417,9 +2399,7 @@ "ctxt": 0 }, "value": "", - "before": "", - "raw": "", - "after": "" + "raw": "" }, "modifiers": null }, @@ -2827,9 +2807,7 @@ "ctxt": 0 }, "value": "", - "before": "", - "raw": "", - "after": "" + "raw": "" }, "modifiers": null }, @@ -3003,9 +2981,7 @@ "ctxt": 0 }, "value": "test.css", - "before": "", - "raw": "test.css", - "after": "" + "raw": "test.css" }, "modifiers": null }, @@ -3148,9 +3124,7 @@ "ctxt": 0 }, "value": "test.css", - "before": "", - "raw": "test.css", - "after": "" + "raw": "test.css" }, "modifiers": null }, @@ -3293,9 +3267,7 @@ "ctxt": 0 }, "value": "test.css", - "before": "", - "raw": "test.css", - "after": "" + "raw": "test.css" }, "modifiers": null }, @@ -3438,9 +3410,7 @@ "ctxt": 0 }, "value": "test.css", - "before": "", - "raw": "test.css", - "after": "" + "raw": "test.css" }, "modifiers": null }, @@ -3583,9 +3553,7 @@ "ctxt": 0 }, "value": "test.css", - "before": "", - "raw": "test.css", - "after": "" + "raw": "test.css" }, "modifiers": null }, @@ -3786,9 +3754,7 @@ "ctxt": 0 }, "value": "~package/test.css", - "before": "", - "raw": "~package/test.css", - "after": "" + "raw": "~package/test.css" }, "modifiers": null }, @@ -4136,9 +4102,7 @@ "ctxt": 0 }, "value": "~package/tilde.css", - "before": "", - "raw": "~package/tilde.css", - "after": "" + "raw": "~package/tilde.css" }, "modifiers": null }, @@ -4196,9 +4160,7 @@ "ctxt": 0 }, "value": "~aliasesImport/alias.css", - "before": "", - "raw": "~aliasesImport/alias.css", - "after": "" + "raw": "~aliasesImport/alias.css" }, "modifiers": null }, @@ -4314,9 +4276,7 @@ "ctxt": 0 }, "value": "./test.css", - "before": "", - "raw": "./test.css", - "after": "" + "raw": "./test.css" }, "modifiers": null }, @@ -5247,9 +5207,7 @@ "ctxt": 0 }, "value": "./test test.css", - "before": "", - "raw": "./test\\ test.css", - "after": "" + "raw": "./test\\ test.css" }, "modifiers": null }, @@ -5307,9 +5265,7 @@ "ctxt": 0 }, "value": "./test%20test.css", - "before": "", - "raw": "./t\\65st%20test.css", - "after": "" + "raw": "./t\\65st%20test.css" }, "modifiers": null }, @@ -5561,9 +5517,7 @@ "ctxt": 0 }, "value": "test.css", - "before": " ", - "raw": "test.css", - "after": " " + "raw": " test.css " }, "modifiers": null }, @@ -5718,9 +5672,7 @@ "ctxt": 0 }, "value": "test.css?foo=bar", - "before": "", - "raw": "test.css?foo=bar", - "after": "" + "raw": "test.css?foo=bar" }, "modifiers": null }, @@ -5778,9 +5730,7 @@ "ctxt": 0 }, "value": "test.css?foo=bar#hash", - "before": "", - "raw": "test.css?foo=bar#hash", - "after": "" + "raw": "test.css?foo=bar#hash" }, "modifiers": null }, @@ -5838,9 +5788,7 @@ "ctxt": 0 }, "value": "test.css?#hash", - "before": "", - "raw": "test.css?#hash", - "after": "" + "raw": "test.css?#hash" }, "modifiers": null }, @@ -6441,9 +6389,7 @@ "ctxt": 0 }, "value": "./test.css", - "before": " ", - "raw": "./test.css", - "after": " " + "raw": " ./test.css " }, "modifiers": null }, @@ -6714,9 +6660,7 @@ "ctxt": 0 }, "value": "data:text/css;charset=utf-8,a%20%7B%0D%0A%20%20color%3A%20red%3B%0D%0A%7D", - "before": "", - "raw": "data:text/css;charset=utf-8,a%20%7B%0D%0A%20%20color%3A%20red%3B%0D%0A%7D", - "after": "" + "raw": "data:text/css;charset=utf-8,a%20%7B%0D%0A%20%20color%3A%20red%3B%0D%0A%7D" }, "modifiers": null }, @@ -6774,9 +6718,7 @@ "ctxt": 0 }, "value": "package/first.css", - "before": "", - "raw": "package/first.css", - "after": "" + "raw": "package/first.css" }, "modifiers": null }, @@ -6834,9 +6776,7 @@ "ctxt": 0 }, "value": "package/second.css", - "before": "", - "raw": "package/second.css", - "after": "" + "raw": "package/second.css" }, "modifiers": null }, @@ -9734,9 +9674,7 @@ "ctxt": 0 }, "value": "test.css", - "before": "", - "raw": "test.css", - "after": "" + "raw": "test.css" }, "modifiers": null }, @@ -9794,9 +9732,7 @@ "ctxt": 0 }, "value": "test.css", - "before": "", - "raw": "test.css", - "after": "" + "raw": "test.css" }, "modifiers": null }, @@ -9854,9 +9790,7 @@ "ctxt": 0 }, "value": "test.css", - "before": "", - "raw": "test.css", - "after": "" + "raw": "test.css" }, "modifiers": null }, @@ -9999,9 +9933,7 @@ "ctxt": 0 }, "value": "test.css", - "before": "", - "raw": "test.css", - "after": "" + "raw": "test.css" }, "modifiers": null }, @@ -11532,9 +11464,7 @@ "ctxt": 0 }, "value": "bootstrap-base.css", - "before": "", - "raw": "bootstrap-base.css", - "after": "" + "raw": "bootstrap-base.css" }, "modifiers": null }, @@ -11631,9 +11561,7 @@ "ctxt": 0 }, "value": "base-headings.css", - "before": "", - "raw": "base-headings.css", - "after": "" + "raw": "base-headings.css" }, "modifiers": null }, diff --git a/crates/swc_css_parser/tests/fixture/at-rule/namespace/output.json b/crates/swc_css_parser/tests/fixture/at-rule/namespace/output.json index 7056a12148a..0e57db1c169 100644 --- a/crates/swc_css_parser/tests/fixture/at-rule/namespace/output.json +++ b/crates/swc_css_parser/tests/fixture/at-rule/namespace/output.json @@ -141,9 +141,7 @@ "ctxt": 0 }, "value": "http://www.w3.org/1999/xhtml", - "before": "", - "raw": "http://www.w3.org/1999/xhtml", - "after": "" + "raw": "http://www.w3.org/1999/xhtml" }, "modifiers": null } @@ -266,9 +264,7 @@ "ctxt": 0 }, "value": "http://www.w3.org/2000/svg", - "before": "", - "raw": "http://www.w3.org/2000/svg", - "after": "" + "raw": "http://www.w3.org/2000/svg" }, "modifiers": null } diff --git a/crates/swc_css_parser/tests/fixture/csstree/1/output.json b/crates/swc_css_parser/tests/fixture/csstree/1/output.json index 320a5924fcb..7c498de24a7 100644 --- a/crates/swc_css_parser/tests/fixture/csstree/1/output.json +++ b/crates/swc_css_parser/tests/fixture/csstree/1/output.json @@ -1835,9 +1835,7 @@ "ctxt": 0 }, "value": "path/to.png", - "before": "", - "raw": "path/to.png", - "after": "" + "raw": "path/to.png" }, "modifiers": null }, diff --git a/crates/swc_css_parser/tests/fixture/declaration/output.json b/crates/swc_css_parser/tests/fixture/declaration/output.json index bfe10bc3c12..f20f9dfa2fc 100644 --- a/crates/swc_css_parser/tests/fixture/declaration/output.json +++ b/crates/swc_css_parser/tests/fixture/declaration/output.json @@ -782,9 +782,7 @@ "ctxt": 0 }, "value": "value", - "before": "", - "raw": "value", - "after": "" + "raw": "value" }, "modifiers": null }, @@ -813,9 +811,7 @@ "ctxt": 0 }, "value": "value", - "before": "", - "raw": "value", - "after": "" + "raw": "value" }, "modifiers": null } diff --git a/crates/swc_css_parser/tests/fixture/esbuild/misc/8Gs_Q4kYqijbgIQ6xIW8qw/output.json b/crates/swc_css_parser/tests/fixture/esbuild/misc/8Gs_Q4kYqijbgIQ6xIW8qw/output.json index d2ff1c67d3a..f47af4f0c85 100644 --- a/crates/swc_css_parser/tests/fixture/esbuild/misc/8Gs_Q4kYqijbgIQ6xIW8qw/output.json +++ b/crates/swc_css_parser/tests/fixture/esbuild/misc/8Gs_Q4kYqijbgIQ6xIW8qw/output.json @@ -130,9 +130,7 @@ "ctxt": 0 }, "value": "aج", - "before": "", - "raw": "a\\62c", - "after": "" + "raw": "a\\62c" }, "modifiers": null } diff --git a/crates/swc_css_parser/tests/fixture/esbuild/misc/FU0reCXb694XEXwdM2wqsQ/output.json b/crates/swc_css_parser/tests/fixture/esbuild/misc/FU0reCXb694XEXwdM2wqsQ/output.json index 83dec871921..3978f3a346d 100644 --- a/crates/swc_css_parser/tests/fixture/esbuild/misc/FU0reCXb694XEXwdM2wqsQ/output.json +++ b/crates/swc_css_parser/tests/fixture/esbuild/misc/FU0reCXb694XEXwdM2wqsQ/output.json @@ -55,9 +55,7 @@ "ctxt": 0 }, "value": "foo.css", - "before": "", - "raw": "foo.css", - "after": "" + "raw": "foo.css" }, "modifiers": null }, diff --git a/crates/swc_css_parser/tests/fixture/esbuild/misc/Uuvi9sS4YR_ILpKl0xpfOg/output.json b/crates/swc_css_parser/tests/fixture/esbuild/misc/Uuvi9sS4YR_ILpKl0xpfOg/output.json index af8e48ff0f8..06c5d6d105c 100644 --- a/crates/swc_css_parser/tests/fixture/esbuild/misc/Uuvi9sS4YR_ILpKl0xpfOg/output.json +++ b/crates/swc_css_parser/tests/fixture/esbuild/misc/Uuvi9sS4YR_ILpKl0xpfOg/output.json @@ -130,9 +130,7 @@ "ctxt": 0 }, "value": "abc", - "before": "", - "raw": "a\\62 c", - "after": "" + "raw": "a\\62 c" }, "modifiers": null } diff --git a/crates/swc_css_parser/tests/fixture/esbuild/misc/dCIAD8Ab98J4V9rGaJvZlw/output.json b/crates/swc_css_parser/tests/fixture/esbuild/misc/dCIAD8Ab98J4V9rGaJvZlw/output.json index 0e4ed47ad6d..9940f72b5e1 100644 --- a/crates/swc_css_parser/tests/fixture/esbuild/misc/dCIAD8Ab98J4V9rGaJvZlw/output.json +++ b/crates/swc_css_parser/tests/fixture/esbuild/misc/dCIAD8Ab98J4V9rGaJvZlw/output.json @@ -130,9 +130,7 @@ "ctxt": 0 }, "value": ",", - "before": "", - "raw": "\\,", - "after": "" + "raw": "\\," }, "modifiers": null } diff --git a/crates/swc_css_parser/tests/fixture/esbuild/misc/eqYc139qNzkqXqBaJaQm6A/output.json b/crates/swc_css_parser/tests/fixture/esbuild/misc/eqYc139qNzkqXqBaJaQm6A/output.json index e361290b34d..2e3163bbb35 100644 --- a/crates/swc_css_parser/tests/fixture/esbuild/misc/eqYc139qNzkqXqBaJaQm6A/output.json +++ b/crates/swc_css_parser/tests/fixture/esbuild/misc/eqYc139qNzkqXqBaJaQm6A/output.json @@ -55,9 +55,7 @@ "ctxt": 0 }, "value": "foo.css", - "before": "", - "raw": "foo.css", - "after": "" + "raw": "foo.css" }, "modifiers": null }, diff --git a/crates/swc_css_parser/tests/fixture/esbuild/misc/fmt94qCRfRXbpej5kzLZUw/output.json b/crates/swc_css_parser/tests/fixture/esbuild/misc/fmt94qCRfRXbpej5kzLZUw/output.json index f3b92389238..a7f78a65677 100644 --- a/crates/swc_css_parser/tests/fixture/esbuild/misc/fmt94qCRfRXbpej5kzLZUw/output.json +++ b/crates/swc_css_parser/tests/fixture/esbuild/misc/fmt94qCRfRXbpej5kzLZUw/output.json @@ -130,9 +130,7 @@ "ctxt": 0 }, "value": ",", - "before": "", - "raw": "\\2c", - "after": "" + "raw": "\\2c" }, "modifiers": null } diff --git a/crates/swc_css_parser/tests/fixture/esbuild/misc/gPpnAqOuxEdLAEJjFaUEkg/output.json b/crates/swc_css_parser/tests/fixture/esbuild/misc/gPpnAqOuxEdLAEJjFaUEkg/output.json index 1e8f8ea9bb5..ccdac9725b2 100644 --- a/crates/swc_css_parser/tests/fixture/esbuild/misc/gPpnAqOuxEdLAEJjFaUEkg/output.json +++ b/crates/swc_css_parser/tests/fixture/esbuild/misc/gPpnAqOuxEdLAEJjFaUEkg/output.json @@ -130,9 +130,7 @@ "ctxt": 0 }, "value": "abc", - "before": "", - "raw": "\\61 bc", - "after": "" + "raw": "\\61 bc" }, "modifiers": null } diff --git a/crates/swc_css_parser/tests/fixture/esbuild/misc/i3YGyP16CjaKe5cnWygVeQ/output.json b/crates/swc_css_parser/tests/fixture/esbuild/misc/i3YGyP16CjaKe5cnWygVeQ/output.json index 851c9bb95eb..93667995601 100644 --- a/crates/swc_css_parser/tests/fixture/esbuild/misc/i3YGyP16CjaKe5cnWygVeQ/output.json +++ b/crates/swc_css_parser/tests/fixture/esbuild/misc/i3YGyP16CjaKe5cnWygVeQ/output.json @@ -55,9 +55,7 @@ "ctxt": 0 }, "value": "", - "before": "", - "raw": "", - "after": "" + "raw": "" }, "modifiers": null }, diff --git a/crates/swc_css_parser/tests/fixture/esbuild/misc/mx296i8q4HfA0IzZ055Xpw/output.json b/crates/swc_css_parser/tests/fixture/esbuild/misc/mx296i8q4HfA0IzZ055Xpw/output.json index 39bfa088299..baa4b9f8629 100644 --- a/crates/swc_css_parser/tests/fixture/esbuild/misc/mx296i8q4HfA0IzZ055Xpw/output.json +++ b/crates/swc_css_parser/tests/fixture/esbuild/misc/mx296i8q4HfA0IzZ055Xpw/output.json @@ -130,9 +130,7 @@ "ctxt": 0 }, "value": "憼", - "before": "", - "raw": "\\61bc", - "after": "" + "raw": "\\61bc" }, "modifiers": null } diff --git a/crates/swc_css_parser/tests/fixture/function/url/output.json b/crates/swc_css_parser/tests/fixture/function/url/output.json index eb009d18db5..c7a7d370cab 100644 --- a/crates/swc_css_parser/tests/fixture/function/url/output.json +++ b/crates/swc_css_parser/tests/fixture/function/url/output.json @@ -130,9 +130,7 @@ "ctxt": 0 }, "value": "data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7", - "before": "", - "raw": "data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7", - "after": "" + "raw": "data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7" }, "modifiers": null } @@ -532,9 +530,7 @@ "ctxt": 0 }, "value": "", - "before": "", - "raw": "", - "after": "" + "raw": "" }, "modifiers": null } @@ -584,9 +580,7 @@ "ctxt": 0 }, "value": "", - "before": " ", - "raw": "", - "after": "" + "raw": " " }, "modifiers": null } @@ -886,9 +880,7 @@ "ctxt": 0 }, "value": "./image.png", - "before": "", - "raw": "./image.png", - "after": "" + "raw": "./image.png" }, "modifiers": null } @@ -938,9 +930,7 @@ "ctxt": 0 }, "value": "./image.png", - "before": " ", - "raw": "./image.png", - "after": " " + "raw": " ./image.png " }, "modifiers": null } @@ -990,9 +980,7 @@ "ctxt": 0 }, "value": "./image2.png", - "before": " ", - "raw": "./image\\32.png", - "after": " " + "raw": " ./image\\32.png " }, "modifiers": null } @@ -1042,9 +1030,7 @@ "ctxt": 0 }, "value": "./image2.png", - "before": " \n ", - "raw": "./image\\32.png", - "after": " \n " + "raw": " \n ./image\\32.png \n " }, "modifiers": null } @@ -1094,9 +1080,7 @@ "ctxt": 0 }, "value": "./image2.png", - "before": "\n \n \n \n ", - "raw": "./image\\32.png", - "after": "\n \n \n \n " + "raw": "\n \n \n \n ./image\\32.png\n \n \n \n " }, "modifiers": null } @@ -1146,9 +1130,7 @@ "ctxt": 0 }, "value": "./image2.png", - "before": " \n\n\n\n ", - "raw": "./image\\32.png", - "after": "\n\n\n\n " + "raw": " \n\n\n\n ./image\\32.png\n\n\n\n " }, "modifiers": null } @@ -1198,9 +1180,7 @@ "ctxt": 0 }, "value": "image.png\u0001", - "before": "", - "raw": "image.png\\0001", - "after": "" + "raw": "image.png\\0001" }, "modifiers": null } @@ -1250,9 +1230,7 @@ "ctxt": 0 }, "value": "image.png\u0001", - "before": "", - "raw": "image.png\\1", - "after": "" + "raw": "image.png\\1" }, "modifiers": null } @@ -1302,9 +1280,7 @@ "ctxt": 0 }, "value": "image.png힙", - "before": "", - "raw": "image.png\\D799", - "after": "" + "raw": "image.png\\D799" }, "modifiers": null } @@ -1354,9 +1330,7 @@ "ctxt": 0 }, "value": "image.png", - "before": "", - "raw": "image.png\\E000", - "after": "" + "raw": "image.png\\E000" }, "modifiers": null } @@ -1406,9 +1380,7 @@ "ctxt": 0 }, "value": "image.png􏿿", - "before": "", - "raw": "image.png\\10FFFF", - "after": "" + "raw": "image.png\\10FFFF" }, "modifiers": null } @@ -1458,9 +1430,7 @@ "ctxt": 0 }, "value": "18", - "before": "", - "raw": "18", - "after": "" + "raw": "18" }, "modifiers": null } diff --git a/crates/swc_css_parser/tests/fixture/hex-colors/input.css b/crates/swc_css_parser/tests/fixture/hex-colors/input.css index 2fd80900901..f7a6a696026 100644 --- a/crates/swc_css_parser/tests/fixture/hex-colors/input.css +++ b/crates/swc_css_parser/tests/fixture/hex-colors/input.css @@ -14,4 +14,5 @@ a { color: #FF; color: #123456789; color: #xyz; + color: #aa\61; } diff --git a/crates/swc_css_parser/tests/fixture/hex-colors/output.json b/crates/swc_css_parser/tests/fixture/hex-colors/output.json index aa6c244e849..052782f5813 100644 --- a/crates/swc_css_parser/tests/fixture/hex-colors/output.json +++ b/crates/swc_css_parser/tests/fixture/hex-colors/output.json @@ -2,7 +2,7 @@ "type": "Stylesheet", "span": { "start": 1, - "end": 257, + "end": 274, "ctxt": 0 }, "rules": [ @@ -10,7 +10,7 @@ "type": "QualifiedRule", "span": { "start": 1, - "end": 256, + "end": 273, "ctxt": 0 }, "prelude": { @@ -74,7 +74,7 @@ "type": "SimpleBlock", "span": { "start": 3, - "end": 256, + "end": 273, "ctxt": 0 }, "name": { @@ -551,6 +551,37 @@ } ], "important": null + }, + { + "type": "Declaration", + "span": { + "start": 257, + "end": 270, + "ctxt": 0 + }, + "name": { + "type": "Ident", + "span": { + "start": 257, + "end": 262, + "ctxt": 0 + }, + "value": "color", + "raw": "color" + }, + "value": [ + { + "type": "HexColor", + "span": { + "start": 264, + "end": 270, + "ctxt": 0 + }, + "value": "aaa", + "raw": "aa\\61" + } + ], + "important": null } ] } diff --git a/crates/swc_css_parser/tests/fixture/hex-colors/span.rust-debug b/crates/swc_css_parser/tests/fixture/hex-colors/span.rust-debug index 6db9f383a8c..e9e940fa61b 100644 --- a/crates/swc_css_parser/tests/fixture/hex-colors/span.rust-debug +++ b/crates/swc_css_parser/tests/fixture/hex-colors/span.rust-debug @@ -17,7 +17,8 @@ 14 | | color: #FF; 15 | | color: #123456789; 16 | | color: #xyz; - 17 | `-> } + 17 | | color: #aa\61; + 18 | `-> } `---- x Rule @@ -38,7 +39,8 @@ 14 | | color: #FF; 15 | | color: #123456789; 16 | | color: #xyz; - 17 | `-> } + 17 | | color: #aa\61; + 18 | `-> } `---- x QualifiedRule @@ -59,7 +61,8 @@ 14 | | color: #FF; 15 | | color: #123456789; 16 | | color: #xyz; - 17 | `-> } + 17 | | color: #aa\61; + 18 | `-> } `---- x SelectorList @@ -122,7 +125,8 @@ 14 | | color: #FF; 15 | | color: #123456789; 16 | | color: #xyz; - 17 | `-> } + 17 | | color: #aa\61; + 18 | `-> } `---- x LBrace @@ -850,3 +854,51 @@ 16 | color: #xyz; : ^^^^ `---- + + x ComponentValue + ,-[$DIR/tests/fixture/hex-colors/input.css:17:3] + 17 | color: #aa\61; + : ^^^^^^^^^^^^^ + `---- + + x StyleBlock + ,-[$DIR/tests/fixture/hex-colors/input.css:17:3] + 17 | color: #aa\61; + : ^^^^^^^^^^^^^ + `---- + + x Declaration + ,-[$DIR/tests/fixture/hex-colors/input.css:17:3] + 17 | color: #aa\61; + : ^^^^^^^^^^^^^ + `---- + + x DeclarationName + ,-[$DIR/tests/fixture/hex-colors/input.css:17:3] + 17 | color: #aa\61; + : ^^^^^ + `---- + + x Ident + ,-[$DIR/tests/fixture/hex-colors/input.css:17:3] + 17 | color: #aa\61; + : ^^^^^ + `---- + + x ComponentValue + ,-[$DIR/tests/fixture/hex-colors/input.css:17:3] + 17 | color: #aa\61; + : ^^^^^^ + `---- + + x Color + ,-[$DIR/tests/fixture/hex-colors/input.css:17:3] + 17 | color: #aa\61; + : ^^^^^^ + `---- + + x HexColor + ,-[$DIR/tests/fixture/hex-colors/input.css:17:3] + 17 | color: #aa\61; + : ^^^^^^ + `---- diff --git a/crates/swc_css_parser/tests/fixture/selector/pseudo-class/unknown/output.json b/crates/swc_css_parser/tests/fixture/selector/pseudo-class/unknown/output.json index 31d85d044cd..531f1c88f2c 100644 --- a/crates/swc_css_parser/tests/fixture/selector/pseudo-class/unknown/output.json +++ b/crates/swc_css_parser/tests/fixture/selector/pseudo-class/unknown/output.json @@ -1771,8 +1771,6 @@ "Url": { "name": "url", "raw_name": "url", - "before": "", - "after": "", "value": "foo.png", "raw_value": "foo.png" } diff --git a/crates/swc_css_parser/tests/fixture/selector/pseudo-class/unknown/span.rust-debug b/crates/swc_css_parser/tests/fixture/selector/pseudo-class/unknown/span.rust-debug index f54200d69a6..210988ec0fa 100644 --- a/crates/swc_css_parser/tests/fixture/selector/pseudo-class/unknown/span.rust-debug +++ b/crates/swc_css_parser/tests/fixture/selector/pseudo-class/unknown/span.rust-debug @@ -1541,8 +1541,7 @@ : ^^^^^^^^^^^^ `---- - x Url { name: Atom('url' type=static), raw_name: Atom('url' type=static), before: Atom('' type=static), after: Atom('' type=static), value: Atom('foo.png' type=inline), raw_value: Atom('foo.png' - | type=inline) } + x Url { name: Atom('url' type=static), raw_name: Atom('url' type=static), value: Atom('foo.png' type=inline), raw_value: Atom('foo.png' type=inline) } ,-[$DIR/tests/fixture/selector/pseudo-class/unknown/input.css:15:1] 15 | :unknown(url(foo.png)) {} : ^^^^^^^^^^^^ diff --git a/crates/swc_css_parser/tests/fixture/selector/pseudo-element/unknown/output.json b/crates/swc_css_parser/tests/fixture/selector/pseudo-element/unknown/output.json index 96e4a004aa6..46d3f3756c1 100644 --- a/crates/swc_css_parser/tests/fixture/selector/pseudo-element/unknown/output.json +++ b/crates/swc_css_parser/tests/fixture/selector/pseudo-element/unknown/output.json @@ -1771,8 +1771,6 @@ "Url": { "name": "url", "raw_name": "url", - "before": "", - "after": "", "value": "foo.png", "raw_value": "foo.png" } diff --git a/crates/swc_css_parser/tests/fixture/selector/pseudo-element/unknown/span.rust-debug b/crates/swc_css_parser/tests/fixture/selector/pseudo-element/unknown/span.rust-debug index 02cf0d9e119..d794de25bb4 100644 --- a/crates/swc_css_parser/tests/fixture/selector/pseudo-element/unknown/span.rust-debug +++ b/crates/swc_css_parser/tests/fixture/selector/pseudo-element/unknown/span.rust-debug @@ -1540,8 +1540,7 @@ : ^^^^^^^^^^^^ `---- - x Url { name: Atom('url' type=static), raw_name: Atom('url' type=static), before: Atom('' type=static), after: Atom('' type=static), value: Atom('foo.png' type=inline), raw_value: Atom('foo.png' - | type=inline) } + x Url { name: Atom('url' type=static), raw_name: Atom('url' type=static), value: Atom('foo.png' type=inline), raw_value: Atom('foo.png' type=inline) } ,-[$DIR/tests/fixture/selector/pseudo-element/unknown/input.css:15:1] 15 | ::unknown(url(foo.png)) {} : ^^^^^^^^^^^^ diff --git a/crates/swc_css_parser/tests/fixture/stylis/comma/01/output.json b/crates/swc_css_parser/tests/fixture/stylis/comma/01/output.json index 0b501ac6c0e..6032d7016c2 100644 --- a/crates/swc_css_parser/tests/fixture/stylis/comma/01/output.json +++ b/crates/swc_css_parser/tests/fixture/stylis/comma/01/output.json @@ -148,9 +148,7 @@ "ctxt": 0 }, "value": "foo.jpg", - "before": "", - "raw": "foo.jpg", - "after": "" + "raw": "foo.jpg" }, "modifiers": null }, diff --git a/crates/swc_css_parser/tests/fixture/value/escaped/output.json b/crates/swc_css_parser/tests/fixture/value/escaped/output.json index 9dee15a1111..50d676d9723 100644 --- a/crates/swc_css_parser/tests/fixture/value/escaped/output.json +++ b/crates/swc_css_parser/tests/fixture/value/escaped/output.json @@ -295,9 +295,7 @@ "ctxt": 0 }, "value": "a;a", - "before": "", - "raw": "a;a", - "after": "" + "raw": "a;a" }, "modifiers": null } @@ -347,9 +345,7 @@ "ctxt": 0 }, "value": "a/*", - "before": "", - "raw": "a/*", - "after": "" + "raw": "a/*" }, "modifiers": null } diff --git a/crates/swc_css_parser/tests/fixture/value/url/output.json b/crates/swc_css_parser/tests/fixture/value/url/output.json index 36dbcece335..5150246736d 100644 --- a/crates/swc_css_parser/tests/fixture/value/url/output.json +++ b/crates/swc_css_parser/tests/fixture/value/url/output.json @@ -130,9 +130,7 @@ "ctxt": 0 }, "value": "https://example.com/image.png", - "before": "", - "raw": "https://example.com/image.png", - "after": "" + "raw": "https://example.com/image.png" }, "modifiers": null } @@ -182,9 +180,7 @@ "ctxt": 0 }, "value": "https://example.com/image.png", - "before": "", - "raw": "https://example.com/image.png", - "after": "" + "raw": "https://example.com/image.png" }, "modifiers": null } @@ -234,9 +230,7 @@ "ctxt": 0 }, "value": "https://example.com/image.png", - "before": "", - "raw": "https://example.com/image.png", - "after": "" + "raw": "https://example.com/image.png" }, "modifiers": null } @@ -486,9 +480,7 @@ "ctxt": 0 }, "value": "data:image/png;base64,iRxVB0", - "before": "", - "raw": "data:image/png;base64,iRxVB0", - "after": "" + "raw": "data:image/png;base64,iRxVB0" }, "modifiers": null } @@ -538,9 +530,7 @@ "ctxt": 0 }, "value": "#IDofSVGpath", - "before": "", - "raw": "#IDofSVGpath", - "after": "" + "raw": "#IDofSVGpath" }, "modifiers": null } @@ -873,9 +863,7 @@ "ctxt": 0 }, "value": "", - "before": "", - "raw": "", - "after": "" + "raw": "" }, "modifiers": null } @@ -1232,9 +1220,7 @@ "ctxt": 0 }, "value": "https://example.com/image.png", - "before": " ", - "raw": "https://example.com/image.png", - "after": " " + "raw": " https://example.com/image.png " }, "modifiers": null } @@ -1284,9 +1270,7 @@ "ctxt": 0 }, "value": "https://example.com/image.png", - "before": " ", - "raw": "https://example.com/image.png", - "after": " " + "raw": " https://example.com/image.png " }, "modifiers": null } @@ -1336,9 +1320,7 @@ "ctxt": 0 }, "value": "https://example.com/image.png", - "before": " \n ", - "raw": "https://example.com/image.png", - "after": " \n " + "raw": " \n https://example.com/image.png \n " }, "modifiers": null } @@ -1388,9 +1370,7 @@ "ctxt": 0 }, "value": "https://example.com/image.png", - "before": "\n\n\n", - "raw": "https://example.com/image.png", - "after": "\n\n\n" + "raw": "\n\n\nhttps://example.com/image.png\n\n\n" }, "modifiers": null } @@ -1440,9 +1420,7 @@ "ctxt": 0 }, "value": "https://example.com/ima)ge.png", - "before": "", - "raw": "https://example.com/ima\\)ge.png", - "after": "" + "raw": "https://example.com/ima\\)ge.png" }, "modifiers": null } diff --git a/crates/swc_css_parser/tests/recovery/bad-url-token/double-quotes/output.json b/crates/swc_css_parser/tests/recovery/bad-url-token/double-quotes/output.json index b29f2330d90..16f777bb37f 100644 --- a/crates/swc_css_parser/tests/recovery/bad-url-token/double-quotes/output.json +++ b/crates/swc_css_parser/tests/recovery/bad-url-token/double-quotes/output.json @@ -116,7 +116,6 @@ "BadUrl": { "name": "url", "raw_name": "url", - "value": "image\".png", "raw_value": "image\".png" } } diff --git a/crates/swc_css_parser/tests/recovery/bad-url-token/double-quotes/span.rust-debug b/crates/swc_css_parser/tests/recovery/bad-url-token/double-quotes/span.rust-debug index 2ba2b1279cb..93d0fd9c867 100644 --- a/crates/swc_css_parser/tests/recovery/bad-url-token/double-quotes/span.rust-debug +++ b/crates/swc_css_parser/tests/recovery/bad-url-token/double-quotes/span.rust-debug @@ -115,7 +115,7 @@ : ^^^^^^^^^^^^^^^ `---- - x BadUrl { name: Atom('url' type=static), raw_name: Atom('url' type=static), value: Atom('image".png' type=dynamic), raw_value: Atom('image".png' type=dynamic) } + x BadUrl { name: Atom('url' type=static), raw_name: Atom('url' type=static), raw_value: Atom('image".png' type=dynamic) } ,-[$DIR/tests/recovery/bad-url-token/double-quotes/input.css:2:5] 2 | background: url(image".png); : ^^^^^^^^^^^^^^^ diff --git a/crates/swc_css_parser/tests/recovery/bad-url-token/invalid-escape/output.json b/crates/swc_css_parser/tests/recovery/bad-url-token/invalid-escape/output.json index 135ee8b78cc..cacec20971c 100644 --- a/crates/swc_css_parser/tests/recovery/bad-url-token/invalid-escape/output.json +++ b/crates/swc_css_parser/tests/recovery/bad-url-token/invalid-escape/output.json @@ -116,7 +116,6 @@ "BadUrl": { "name": "url", "raw_name": "url", - "value": "image.png\\\n ", "raw_value": "image.png\\\n " } } diff --git a/crates/swc_css_parser/tests/recovery/bad-url-token/invalid-escape/span.rust-debug b/crates/swc_css_parser/tests/recovery/bad-url-token/invalid-escape/span.rust-debug index ebd9cd82f33..ad77d57019d 100644 --- a/crates/swc_css_parser/tests/recovery/bad-url-token/invalid-escape/span.rust-debug +++ b/crates/swc_css_parser/tests/recovery/bad-url-token/invalid-escape/span.rust-debug @@ -115,8 +115,7 @@ 3 | `-> ); `---- - x BadUrl { name: Atom('url' type=static), raw_name: Atom('url' type=static), value: Atom('image.png\ - | ' type=dynamic), raw_value: Atom('image.png\ + x BadUrl { name: Atom('url' type=static), raw_name: Atom('url' type=static), raw_value: Atom('image.png\ | ' type=dynamic) } ,-[$DIR/tests/recovery/bad-url-token/invalid-escape/input.css:2:5] 2 | ,-> background: url(image.png\ diff --git a/crates/swc_css_parser/tests/recovery/bad-url-token/left-parenthesis/output.json b/crates/swc_css_parser/tests/recovery/bad-url-token/left-parenthesis/output.json index 5d312f8f7b6..42e54f48eb4 100644 --- a/crates/swc_css_parser/tests/recovery/bad-url-token/left-parenthesis/output.json +++ b/crates/swc_css_parser/tests/recovery/bad-url-token/left-parenthesis/output.json @@ -116,7 +116,6 @@ "BadUrl": { "name": "url", "raw_name": "url", - "value": "image(.png", "raw_value": "image(.png" } } diff --git a/crates/swc_css_parser/tests/recovery/bad-url-token/left-parenthesis/span.rust-debug b/crates/swc_css_parser/tests/recovery/bad-url-token/left-parenthesis/span.rust-debug index f7bbbdf1239..3bdde4a6756 100644 --- a/crates/swc_css_parser/tests/recovery/bad-url-token/left-parenthesis/span.rust-debug +++ b/crates/swc_css_parser/tests/recovery/bad-url-token/left-parenthesis/span.rust-debug @@ -115,7 +115,7 @@ : ^^^^^^^^^^^^^^^ `---- - x BadUrl { name: Atom('url' type=static), raw_name: Atom('url' type=static), value: Atom('image(.png' type=dynamic), raw_value: Atom('image(.png' type=dynamic) } + x BadUrl { name: Atom('url' type=static), raw_name: Atom('url' type=static), raw_value: Atom('image(.png' type=dynamic) } ,-[$DIR/tests/recovery/bad-url-token/left-parenthesis/input.css:2:5] 2 | background: url(image(.png); : ^^^^^^^^^^^^^^^ diff --git a/crates/swc_css_parser/tests/recovery/bad-url-token/single-quotes/output.json b/crates/swc_css_parser/tests/recovery/bad-url-token/single-quotes/output.json index ef558a1ee29..3205f7476f8 100644 --- a/crates/swc_css_parser/tests/recovery/bad-url-token/single-quotes/output.json +++ b/crates/swc_css_parser/tests/recovery/bad-url-token/single-quotes/output.json @@ -116,7 +116,6 @@ "BadUrl": { "name": "url", "raw_name": "url", - "value": "image'.png", "raw_value": "image'.png" } } diff --git a/crates/swc_css_parser/tests/recovery/bad-url-token/single-quotes/span.rust-debug b/crates/swc_css_parser/tests/recovery/bad-url-token/single-quotes/span.rust-debug index 2bf98e5f4d5..12117e4d6a9 100644 --- a/crates/swc_css_parser/tests/recovery/bad-url-token/single-quotes/span.rust-debug +++ b/crates/swc_css_parser/tests/recovery/bad-url-token/single-quotes/span.rust-debug @@ -115,7 +115,7 @@ : ^^^^^^^^^^^^^^^ `---- - x BadUrl { name: Atom('url' type=static), raw_name: Atom('url' type=static), value: Atom('image'.png' type=dynamic), raw_value: Atom('image'.png' type=dynamic) } + x BadUrl { name: Atom('url' type=static), raw_name: Atom('url' type=static), raw_value: Atom('image'.png' type=dynamic) } ,-[$DIR/tests/recovery/bad-url-token/single-quotes/input.css:2:5] 2 | background: url(image'.png); : ^^^^^^^^^^^^^^^ diff --git a/crates/swc_css_parser/tests/recovery/bad-url-token/whitespace-in-middle/output.json b/crates/swc_css_parser/tests/recovery/bad-url-token/whitespace-in-middle/output.json index f43b64875b6..c21c2da11bb 100644 --- a/crates/swc_css_parser/tests/recovery/bad-url-token/whitespace-in-middle/output.json +++ b/crates/swc_css_parser/tests/recovery/bad-url-token/whitespace-in-middle/output.json @@ -116,7 +116,6 @@ "BadUrl": { "name": "url", "raw_name": "url", - "value": " ./image.jpg a ", "raw_value": " ./image.jpg a " } } diff --git a/crates/swc_css_parser/tests/recovery/bad-url-token/whitespace-in-middle/span.rust-debug b/crates/swc_css_parser/tests/recovery/bad-url-token/whitespace-in-middle/span.rust-debug index c129da5fc65..d5ede0e7e34 100644 --- a/crates/swc_css_parser/tests/recovery/bad-url-token/whitespace-in-middle/span.rust-debug +++ b/crates/swc_css_parser/tests/recovery/bad-url-token/whitespace-in-middle/span.rust-debug @@ -111,7 +111,7 @@ : ^^^^^^^^^^^^^^^^^^^^^^^^ `---- - x BadUrl { name: Atom('url' type=static), raw_name: Atom('url' type=static), value: Atom(' ./image.jpg a ' type=dynamic), raw_value: Atom(' ./image.jpg a ' type=dynamic) } + x BadUrl { name: Atom('url' type=static), raw_name: Atom('url' type=static), raw_value: Atom(' ./image.jpg a ' type=dynamic) } ,-[$DIR/tests/recovery/bad-url-token/whitespace-in-middle/input.css:2:5] 2 | background-image: url( ./image.jpg a ); : ^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/crates/swc_css_parser/tests/recovery/bad-url-token/whitespace/output.json b/crates/swc_css_parser/tests/recovery/bad-url-token/whitespace/output.json index 3186cca655d..7e58c723fbe 100644 --- a/crates/swc_css_parser/tests/recovery/bad-url-token/whitespace/output.json +++ b/crates/swc_css_parser/tests/recovery/bad-url-token/whitespace/output.json @@ -116,7 +116,6 @@ "BadUrl": { "name": "url", "raw_name": "url", - "value": "image.\n png", "raw_value": "image.\n png" } } diff --git a/crates/swc_css_parser/tests/recovery/bad-url-token/whitespace/span.rust-debug b/crates/swc_css_parser/tests/recovery/bad-url-token/whitespace/span.rust-debug index ed229eb013e..4addb04c576 100644 --- a/crates/swc_css_parser/tests/recovery/bad-url-token/whitespace/span.rust-debug +++ b/crates/swc_css_parser/tests/recovery/bad-url-token/whitespace/span.rust-debug @@ -119,8 +119,7 @@ 3 | `-> png); `---- - x BadUrl { name: Atom('url' type=static), raw_name: Atom('url' type=static), value: Atom('image. - | png' type=dynamic), raw_value: Atom('image. + x BadUrl { name: Atom('url' type=static), raw_name: Atom('url' type=static), raw_value: Atom('image. | png' type=dynamic) } ,-[$DIR/tests/recovery/bad-url-token/whitespace/input.css:2:5] 2 | ,-> background: url(image. diff --git a/crates/swc_css_parser/tests/recovery/function/bad-comment-2/output.json b/crates/swc_css_parser/tests/recovery/function/bad-comment-2/output.json index 1670f591017..95232e7864f 100644 --- a/crates/swc_css_parser/tests/recovery/function/bad-comment-2/output.json +++ b/crates/swc_css_parser/tests/recovery/function/bad-comment-2/output.json @@ -116,7 +116,6 @@ "BadUrl": { "name": "url", "raw_name": "url", - "value": "\n /* test */\n \"test.png\"\n ", "raw_value": "\n /* test */\n \"test.png\"\n " } } diff --git a/crates/swc_css_parser/tests/recovery/function/bad-comment-2/span.rust-debug b/crates/swc_css_parser/tests/recovery/function/bad-comment-2/span.rust-debug index a25fc610730..0ccc5ef1755 100644 --- a/crates/swc_css_parser/tests/recovery/function/bad-comment-2/span.rust-debug +++ b/crates/swc_css_parser/tests/recovery/function/bad-comment-2/span.rust-debug @@ -131,10 +131,7 @@ 5 | `-> ); `---- - x BadUrl { name: Atom('url' type=static), raw_name: Atom('url' type=static), value: Atom(' - | /* test */ - | "test.png" - | ' type=dynamic), raw_value: Atom(' + x BadUrl { name: Atom('url' type=static), raw_name: Atom('url' type=static), raw_value: Atom(' | /* test */ | "test.png" | ' type=dynamic) } diff --git a/crates/swc_css_parser/tests/recovery/function/bad-comment/output.json b/crates/swc_css_parser/tests/recovery/function/bad-comment/output.json index d15f425c77c..0336f83f2cd 100644 --- a/crates/swc_css_parser/tests/recovery/function/bad-comment/output.json +++ b/crates/swc_css_parser/tests/recovery/function/bad-comment/output.json @@ -116,7 +116,6 @@ "BadUrl": { "name": "url", "raw_name": "url", - "value": "\n /* test */\n test.png\n ", "raw_value": "\n /* test */\n test.png\n " } } diff --git a/crates/swc_css_parser/tests/recovery/function/bad-comment/span.rust-debug b/crates/swc_css_parser/tests/recovery/function/bad-comment/span.rust-debug index ecfd9e62b17..e308e3a2132 100644 --- a/crates/swc_css_parser/tests/recovery/function/bad-comment/span.rust-debug +++ b/crates/swc_css_parser/tests/recovery/function/bad-comment/span.rust-debug @@ -131,10 +131,7 @@ 5 | `-> ); `---- - x BadUrl { name: Atom('url' type=static), raw_name: Atom('url' type=static), value: Atom(' - | /* test */ - | test.png - | ' type=dynamic), raw_value: Atom(' + x BadUrl { name: Atom('url' type=static), raw_name: Atom('url' type=static), raw_value: Atom(' | /* test */ | test.png | ' type=dynamic) } diff --git a/crates/swc_css_parser/tests/recovery/value/quotes/output.json b/crates/swc_css_parser/tests/recovery/value/quotes/output.json index 3e185c4bb4c..739ae033f81 100644 --- a/crates/swc_css_parser/tests/recovery/value/quotes/output.json +++ b/crates/swc_css_parser/tests/recovery/value/quotes/output.json @@ -134,8 +134,7 @@ }, "token": { "BadString": { - "value": "tes", - "raw": "\"tes" + "raw_value": "\"tes" } } }, @@ -175,8 +174,7 @@ }, "token": { "BadString": { - "value": ";", - "raw": "\";" + "raw_value": "\";" } } } diff --git a/crates/swc_css_parser/tests/recovery/value/quotes/span.rust-debug b/crates/swc_css_parser/tests/recovery/value/quotes/span.rust-debug index d4746f10bca..523ba230443 100644 --- a/crates/swc_css_parser/tests/recovery/value/quotes/span.rust-debug +++ b/crates/swc_css_parser/tests/recovery/value/quotes/span.rust-debug @@ -136,7 +136,7 @@ : ^^^^ `---- - x BadString { value: Atom('tes' type=inline), raw: Atom('"tes' type=inline) } + x BadString { raw_value: Atom('"tes' type=inline) } ,-[$DIR/tests/recovery/value/quotes/input.css:2:5] 2 | content: "tes : ^^^^ @@ -173,7 +173,7 @@ : ^^ `---- - x BadString { value: Atom(';' type=inline), raw: Atom('";' type=inline) } + x BadString { raw_value: Atom('";' type=inline) } ,-[$DIR/tests/recovery/value/quotes/input.css:3:5] 3 | t"; : ^^ diff --git a/crates/swc_css_parser/tests/recovery/value/string/newline/output.json b/crates/swc_css_parser/tests/recovery/value/string/newline/output.json index e7f171f1aad..1607251647d 100644 --- a/crates/swc_css_parser/tests/recovery/value/string/newline/output.json +++ b/crates/swc_css_parser/tests/recovery/value/string/newline/output.json @@ -114,8 +114,7 @@ }, "token": { "BadString": { - "value": "", - "raw": "\"" + "raw_value": "\"" } } } diff --git a/crates/swc_css_parser/tests/recovery/value/string/newline/span.rust-debug b/crates/swc_css_parser/tests/recovery/value/string/newline/span.rust-debug index 2318bfcae45..cdb55c76d4c 100644 --- a/crates/swc_css_parser/tests/recovery/value/string/newline/span.rust-debug +++ b/crates/swc_css_parser/tests/recovery/value/string/newline/span.rust-debug @@ -107,7 +107,7 @@ : ^ `---- - x BadString { value: Atom('' type=static), raw: Atom('"' type=inline) } + x BadString { raw_value: Atom('"' type=inline) } ,-[$DIR/tests/recovery/value/string/newline/input.css:2:5] 2 | prop: " : ^ diff --git a/crates/swc_css_parser/tests/recovery/value/url/basic/output.json b/crates/swc_css_parser/tests/recovery/value/url/basic/output.json index 7ab7d93d756..ed8d92f4020 100644 --- a/crates/swc_css_parser/tests/recovery/value/url/basic/output.json +++ b/crates/swc_css_parser/tests/recovery/value/url/basic/output.json @@ -151,7 +151,6 @@ "BadUrl": { "name": "url", "raw_name": "url", - "value": "var(--foo", "raw_value": "var(--foo" } } @@ -202,9 +201,7 @@ "ctxt": 0 }, "value": "image.png�", - "before": "", - "raw": "image.png\\999999", - "after": "" + "raw": "image.png\\999999" }, "modifiers": null } @@ -254,9 +251,7 @@ "ctxt": 0 }, "value": "image.png�", - "before": "", - "raw": "image.png\\0", - "after": "" + "raw": "image.png\\0" }, "modifiers": null } @@ -306,9 +301,7 @@ "ctxt": 0 }, "value": "image.png�", - "before": "", - "raw": "image.png\\D800", - "after": "" + "raw": "image.png\\D800" }, "modifiers": null } @@ -358,9 +351,7 @@ "ctxt": 0 }, "value": "image.png�", - "before": "", - "raw": "image.png\\DFFF", - "after": "" + "raw": "image.png\\DFFF" }, "modifiers": null } @@ -410,9 +401,7 @@ "ctxt": 0 }, "value": "image.png�", - "before": "", - "raw": "image.png\\11FFFF", - "after": "" + "raw": "image.png\\11FFFF" }, "modifiers": null } @@ -556,7 +545,6 @@ "BadUrl": { "name": "url", "raw_name": "url", - "value": "image.png param(var(--url", "raw_value": "image.png param(var(--url" } } diff --git a/crates/swc_css_parser/tests/recovery/value/url/basic/span.rust-debug b/crates/swc_css_parser/tests/recovery/value/url/basic/span.rust-debug index 23db6d69430..484926e9360 100644 --- a/crates/swc_css_parser/tests/recovery/value/url/basic/span.rust-debug +++ b/crates/swc_css_parser/tests/recovery/value/url/basic/span.rust-debug @@ -189,7 +189,7 @@ : ^^^^^^^^^^^^^^ `---- - x BadUrl { name: Atom('url' type=static), raw_name: Atom('url' type=static), value: Atom('var(--foo' type=dynamic), raw_value: Atom('var(--foo' type=dynamic) } + x BadUrl { name: Atom('url' type=static), raw_name: Atom('url' type=static), raw_value: Atom('var(--foo' type=dynamic) } ,-[$DIR/tests/recovery/value/url/basic/input.css:3:5] 3 | background: url(var(--foo)); : ^^^^^^^^^^^^^^ @@ -636,7 +636,7 @@ : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `---- - x BadUrl { name: Atom('url' type=static), raw_name: Atom('url' type=static), value: Atom('image.png param(var(--url' type=dynamic), raw_value: Atom('image.png param(var(--url' type=dynamic) } + x BadUrl { name: Atom('url' type=static), raw_name: Atom('url' type=static), raw_value: Atom('image.png param(var(--url' type=dynamic) } ,-[$DIR/tests/recovery/value/url/basic/input.css:13:5] 13 | background: url(image.png param(var(--url))); : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/crates/swc_css_parser/tests/recovery/value/url/eof/output.json b/crates/swc_css_parser/tests/recovery/value/url/eof/output.json index 53751b8e716..c03edf83df0 100644 --- a/crates/swc_css_parser/tests/recovery/value/url/eof/output.json +++ b/crates/swc_css_parser/tests/recovery/value/url/eof/output.json @@ -130,9 +130,7 @@ "ctxt": 0 }, "value": "foo.png", - "before": "", - "raw": "foo.png", - "after": "" + "raw": "foo.png" }, "modifiers": null } diff --git a/crates/swc_css_parser/tests/recovery/value/url/parenthesis/output.json b/crates/swc_css_parser/tests/recovery/value/url/parenthesis/output.json index a0b4945974a..e6241c5aa5c 100644 --- a/crates/swc_css_parser/tests/recovery/value/url/parenthesis/output.json +++ b/crates/swc_css_parser/tests/recovery/value/url/parenthesis/output.json @@ -116,7 +116,6 @@ "BadUrl": { "name": "url", "raw_name": "url", - "value": "test\\);\n}", "raw_value": "test\\);\n}" } } diff --git a/crates/swc_css_parser/tests/recovery/value/url/parenthesis/span.rust-debug b/crates/swc_css_parser/tests/recovery/value/url/parenthesis/span.rust-debug index 7d760a21f0e..beb9356ce3b 100644 --- a/crates/swc_css_parser/tests/recovery/value/url/parenthesis/span.rust-debug +++ b/crates/swc_css_parser/tests/recovery/value/url/parenthesis/span.rust-debug @@ -111,8 +111,7 @@ 3 | `-> } `---- - x BadUrl { name: Atom('url' type=static), raw_name: Atom('url' type=static), value: Atom('test\); - | }' type=dynamic), raw_value: Atom('test\); + x BadUrl { name: Atom('url' type=static), raw_name: Atom('url' type=static), raw_value: Atom('test\); | }' type=dynamic) } ,-[$DIR/tests/recovery/value/url/parenthesis/input.css:2:5] 2 | ,-> background: url(test\); diff --git a/crates/swc_css_visit/src/lib.rs b/crates/swc_css_visit/src/lib.rs index 5cce357a6b6..6818cdec7dc 100644 --- a/crates/swc_css_visit/src/lib.rs +++ b/crates/swc_css_visit/src/lib.rs @@ -288,9 +288,7 @@ define!({ pub struct UrlValueRaw { pub span: Span, pub value: JsWord, - pub before: Option, pub raw: Option, - pub after: Option, } pub enum UrlModifier {