From d8936ade5b34f682af08e01833d629a67c54f888 Mon Sep 17 00:00:00 2001 From: Alexander Akait <4567934+alexander-akait@users.noreply.github.com> Date: Wed, 7 Dec 2022 06:44:36 +0300 Subject: [PATCH] fix(css/parser): Avoid skipping extra whitespaces (#6592) **Description:** - Avoid skipping whitespaces in `[`/`(`/`{` because it is invalid. Whitespaces can be allowed and can be disallowed based on context, we can't apply this logic to any CSS context. - Also, we already skip whitespaces where it is necessary. - This also avoids extra actions. --- crates/swc_css_parser/src/parser/macros.rs | 26 ---------------------- 1 file changed, 26 deletions(-) diff --git a/crates/swc_css_parser/src/parser/macros.rs b/crates/swc_css_parser/src/parser/macros.rs index 5914f0db9725..c8cccfe9837f 100644 --- a/crates/swc_css_parser/src/parser/macros.rs +++ b/crates/swc_css_parser/src/parser/macros.rs @@ -43,28 +43,6 @@ macro_rules! tok_pat { }; } -macro_rules! can_ignore_ws { - ("{") => { - true - }; - ("}") => { - true - }; - ("(") => { - true - }; - (")") => { - true - }; - (":") => { - true - }; - - ($tt:tt) => { - false - }; -} - macro_rules! cur { ($parser:expr) => { match $parser.input.cur() { @@ -182,10 +160,6 @@ macro_rules! eat { macro_rules! expect { ($parser:expr, $tt:tt) => { - if can_ignore_ws!($tt) { - $parser.input.skip_ws() - } - if !eat!($parser, $tt) { let span = $parser.input.cur_span(); return Err(crate::error::Error::new(