feat(css/ast): Make raw optional (#5211)

This commit is contained in:
Alexander Akait 2022-07-15 14:22:59 +03:00 committed by GitHub
parent aef4d3801c
commit b65a16c7aa
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
44 changed files with 602 additions and 472 deletions

View File

@ -15,7 +15,7 @@ use crate::Function;
pub struct Ident {
pub span: Span,
pub value: JsWord,
pub raw: JsWord,
pub raw: Option<JsWord>,
}
impl EqIgnoreSpan for Ident {
@ -29,7 +29,7 @@ impl EqIgnoreSpan for Ident {
pub struct CustomIdent {
pub span: Span,
pub value: JsWord,
pub raw: JsWord,
pub raw: Option<JsWord>,
}
impl EqIgnoreSpan for CustomIdent {
@ -43,7 +43,7 @@ impl EqIgnoreSpan for CustomIdent {
pub struct DashedIdent {
pub span: Span,
pub value: JsWord,
pub raw: JsWord,
pub raw: Option<JsWord>,
}
impl EqIgnoreSpan for DashedIdent {
@ -57,7 +57,7 @@ impl EqIgnoreSpan for DashedIdent {
pub struct CustomPropertyName {
pub span: Span,
pub value: JsWord,
pub raw: JsWord,
pub raw: Option<JsWord>,
}
impl EqIgnoreSpan for CustomPropertyName {
@ -72,7 +72,7 @@ impl EqIgnoreSpan for CustomPropertyName {
pub struct Str {
pub span: Span,
pub value: JsWord,
pub raw: JsWord,
pub raw: Option<JsWord>,
}
impl EqIgnoreSpan for Str {
@ -131,7 +131,7 @@ pub struct HexColor {
/// Does **not** include `#`
pub value: JsWord,
/// Does **not** include `#`
pub raw: JsWord,
pub raw: Option<JsWord>,
}
#[ast_node]
@ -256,7 +256,7 @@ pub struct Percentage {
pub struct Integer {
pub span: Span,
pub value: i64,
pub raw: JsWord,
pub raw: Option<JsWord>,
}
impl EqIgnoreSpan for Integer {
@ -269,7 +269,7 @@ impl EqIgnoreSpan for Integer {
pub struct Number {
pub span: Span,
pub value: f64,
pub raw: JsWord,
pub raw: Option<JsWord>,
}
impl Eq for Number {}
@ -345,10 +345,10 @@ pub enum UrlValue {
#[derive(Eq, Hash, EqIgnoreSpan)]
pub struct UrlValueRaw {
pub span: Span,
pub before: JsWord,
pub after: JsWord,
pub value: JsWord,
pub raw: JsWord,
pub before: Option<JsWord>,
pub raw: Option<JsWord>,
pub after: Option<JsWord>,
}
#[ast_node]

View File

@ -777,8 +777,12 @@ where
let minified = minify_string(&*n.value);
write_str!(self, n.span, &minified);
} else if let Some(raw) = &n.raw {
write_str!(self, n.span, raw);
} else {
write_str!(self, n.span, &n.raw);
let value = serialize_string(&*n.value);
write_str!(self, n.span, &value);
}
}
@ -996,8 +1000,10 @@ where
if self.config.minify {
value.push_str(&n.value.value.to_lowercase());
} else if let Some(raw) = &n.value.raw {
value.push_str(raw);
} else {
value.push_str(&n.value.raw);
value.push_str("important");
}
write_raw!(self, n.span, &value);
@ -1005,22 +1011,38 @@ where
#[emitter]
fn emit_ident(&mut self, n: &Ident) -> Result {
write_raw!(self, n.span, &n.raw);
if let Some(raw) = &n.raw {
write_raw!(self, n.span, raw);
} else {
write_raw!(self, n.span, &n.value);
}
}
#[emitter]
fn emit_custom_ident(&mut self, n: &CustomIdent) -> Result {
write_raw!(self, n.span, &n.raw);
if let Some(raw) = &n.raw {
write_raw!(self, n.span, raw);
} else {
write_raw!(self, n.span, &n.value);
}
}
#[emitter]
fn emit_dashed_ident(&mut self, n: &DashedIdent) -> Result {
write_raw!(self, n.span, &n.raw);
if let Some(raw) = &n.raw {
write_raw!(self, n.span, raw);
} else {
write_raw!(self, n.span, &n.value);
}
}
#[emitter]
fn emit_custom_property_name(&mut self, n: &CustomPropertyName) -> Result {
write_raw!(self, n.span, &n.raw);
if let Some(raw) = &n.raw {
write_raw!(self, n.span, raw);
} else {
write_raw!(self, n.span, &n.value);
}
}
#[emitter]
@ -1088,8 +1110,10 @@ where
fn emit_integer(&mut self, n: &Integer) -> Result {
if self.config.minify {
write_raw!(self, n.span, &n.value.to_string());
} else if let Some(raw) = &n.raw {
write_raw!(self, n.span, raw);
} else {
write_raw!(self, n.span, &n.raw);
write_raw!(self, n.span, &n.value.to_string());
}
}
@ -1099,8 +1123,10 @@ where
let minified = minify_numeric(n.value);
write_raw!(self, n.span, &minified);
} else if let Some(raw) = &n.raw {
write_raw!(self, n.span, raw);
} else {
write_raw!(self, n.span, &n.raw);
write_raw!(self, n.span, &n.value.to_string());
}
}
@ -1134,7 +1160,7 @@ where
#[emitter]
fn emit_hex_color(&mut self, n: &HexColor) -> Result {
let mut hex_color = String::with_capacity(5);
let mut hex_color = String::with_capacity(9);
hex_color.push('#');
@ -1142,8 +1168,10 @@ where
let minified = minify_hex_color(&n.value);
hex_color.push_str(&minified);
} else if let Some(raw) = &n.raw {
hex_color.push_str(raw);
} else {
hex_color.push_str(&n.raw);
hex_color.push_str(&n.value);
}
write_raw!(self, n.span, &hex_color);
@ -1554,12 +1582,18 @@ where
url.push_str(&n.value);
write_str!(self, n.span, &url);
} else {
let mut url = String::with_capacity(n.before.len() + n.raw.len() + n.after.len());
} 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());
url.push_str(&n.before);
url.push_str(&n.raw);
url.push_str(&n.after);
url.push_str(before);
url.push_str(raw);
url.push_str(after);
write_str!(self, n.span, &url);
} else {
let mut url = String::with_capacity(n.value.len());
url.push_str(&n.value);
write_str!(self, n.span, &url);
}
@ -2057,6 +2091,58 @@ fn minify_hex_color(value: &str) -> String {
value.to_ascii_lowercase()
}
fn serialize_string(value: &str) -> String {
let mut minified = String::with_capacity(value.len());
for c in value.chars() {
match c {
// If the character is NULL (U+0000), then the REPLACEMENT CHARACTER (U+FFFD).
'\0' => {
minified.push('\u{FFFD}');
}
// If the character is in the range [\1-\1f] (U+0001 to U+001F) or is U+007F, the
// character escaped as code point.
'\x01'..='\x1F' | '\x7F' => {
static HEX_DIGITS: &[u8; 16] = b"0123456789abcdef";
let b3;
let b4;
let char_as_u8 = c as u8;
let bytes = if char_as_u8 > 0x0f {
let high = (char_as_u8 >> 4) as usize;
let low = (char_as_u8 & 0x0f) as usize;
b4 = [b'\\', HEX_DIGITS[high], HEX_DIGITS[low], b' '];
&b4[..]
} else {
b3 = [b'\\', HEX_DIGITS[c as usize], b' '];
&b3[..]
};
minified.push_str(from_utf8(bytes).unwrap());
}
// If the character is '"' (U+0022) or "\" (U+005C), the escaped character.
// We avoid escaping `"` to better string compression - we count the quantity of
// quotes to choose the best default quotes
'\\' => {
minified.push_str("\\\\");
}
'"' => {
minified.push_str("\\\"");
}
// Otherwise, the character itself.
_ => {
minified.push(c);
}
};
}
format!("\"{}\"", minified.replace('"', "\\\""))
}
fn minify_string(value: &str) -> String {
let mut minified = String::with_capacity(value.len());

View File

@ -120,14 +120,14 @@ impl VisitMut for NormalizeTest {
n.visit_mut_children_with(self);
n.value = "fff".into();
n.raw = "fff".into();
n.raw = None;
}
fn visit_mut_important_flag(&mut self, n: &mut ImportantFlag) {
n.visit_mut_children_with(self);
n.value.value = n.value.value.to_lowercase().into();
n.value.raw = n.value.raw.to_lowercase().into();
n.value.raw = None;
}
// TODO - we should parse only some properties as `<integer>`, but it requires
@ -140,7 +140,7 @@ impl VisitMut for NormalizeTest {
*n = ComponentValue::Integer(Integer {
span: Default::default(),
value: value.round() as i64,
raw: "".into(),
raw: None,
})
}
_ => {}
@ -150,38 +150,38 @@ impl VisitMut for NormalizeTest {
fn visit_mut_integer(&mut self, n: &mut Integer) {
n.visit_mut_children_with(self);
n.raw = "".into();
n.raw = None;
}
fn visit_mut_number(&mut self, n: &mut Number) {
n.visit_mut_children_with(self);
n.raw = "".into();
n.raw = None;
}
fn visit_mut_str(&mut self, n: &mut Str) {
n.visit_mut_children_with(self);
n.raw = "".into();
n.raw = None;
}
fn visit_mut_url_value_raw(&mut self, n: &mut UrlValueRaw) {
n.visit_mut_children_with(self);
n.before = "".into();
n.after = "".into();
n.raw = "".into();
n.before = None;
n.after = None;
n.raw = None;
}
fn visit_mut_an_plus_b_notation(&mut self, n: &mut AnPlusBNotation) {
n.visit_mut_children_with(self);
if n.a_raw.is_some() {
n.a_raw = Some("".into());
n.a_raw = None;
}
if n.b_raw.is_some() {
n.b_raw = Some("".into());
n.b_raw = None;
}
}

View File

@ -56,7 +56,11 @@ impl FontFamilyNoDuplicateNames {
(fonts, Some((value.to_string(), *span)))
}
}
ComponentValue::Str(Str { raw, span, .. }) => {
ComponentValue::Str(Str {
raw: Some(raw),
span,
..
}) => {
fonts.push((FontNameKind::from(raw), *span));
(fonts, None)
}

View File

@ -25,7 +25,7 @@ impl VisitMut for CompressAlphaValue {
*alpha_value = AlphaValue::Number(Number {
span: *span,
value: new_value,
raw: new_value.to_string().into(),
raw: None,
});
}
AlphaValue::Number(Number { value, span, .. }) if *value < 0.1 => {
@ -36,7 +36,7 @@ impl VisitMut for CompressAlphaValue {
value: Number {
span: DUMMY_SP,
value: new_value,
raw: new_value.to_string().into(),
raw: None,
},
});
}
@ -82,7 +82,7 @@ impl VisitMut for CompressAlphaValue {
*component_value = ComponentValue::Number(Number {
span: *span,
value: new_value,
raw: new_value.to_string().into(),
raw: None,
});
}
_ => {}

View File

@ -72,7 +72,7 @@ impl VisitMut for CompressAngle {
*component_value = ComponentValue::Number(Number {
span: *span,
value: 0.0,
raw: "0".into(),
raw: None,
});
}
_ => {}
@ -102,14 +102,14 @@ impl VisitMut for CompressAngle {
angle.value = Number {
value: deg,
raw: deg.to_string().into(),
raw: None,
span: angle.span,
};
angle.unit = Ident {
span: angle.unit.span,
value: "deg".into(),
raw: "deg".into(),
raw: None,
};
}
}

View File

@ -117,7 +117,7 @@ impl VisitMut for CompressAtRule {
*import_href = ImportPreludeHref::Str(Str {
span: *span,
value: (&*new_value).into(),
raw: (&*new_value).into(),
raw: None,
});
}
}

View File

@ -139,7 +139,7 @@ macro_rules! make_color {
Color::AbsoluteColorBase(AbsoluteColorBase::HexColor(HexColor {
span: $span,
value: value.clone().into(),
raw: value.into(),
raw: None,
}))
} else {
Color::AbsoluteColorBase(AbsoluteColorBase::Function(Function {
@ -147,13 +147,13 @@ macro_rules! make_color {
name: Ident {
span: DUMMY_SP,
value: "rgba".into(),
raw: "rgba".into(),
raw: None,
},
value: vec![
ComponentValue::Number(Number {
span: DUMMY_SP,
value: r,
raw: r.to_string().into(),
raw: None,
}),
ComponentValue::Delimiter(Delimiter {
span: DUMMY_SP,
@ -162,7 +162,7 @@ macro_rules! make_color {
ComponentValue::Number(Number {
span: DUMMY_SP,
value: g,
raw: g.to_string().into(),
raw: None,
}),
ComponentValue::Delimiter(Delimiter {
span: DUMMY_SP,
@ -171,7 +171,7 @@ macro_rules! make_color {
ComponentValue::Number(Number {
span: DUMMY_SP,
value: b,
raw: b.to_string().into(),
raw: None,
}),
ComponentValue::Delimiter(Delimiter {
span: DUMMY_SP,
@ -180,7 +180,7 @@ macro_rules! make_color {
ComponentValue::AlphaValue(AlphaValue::Number(Number {
span: DUMMY_SP,
value: $a,
raw: $a.to_string().into(),
raw: None,
})),
],
}))
@ -192,7 +192,7 @@ macro_rules! make_color {
Color::AbsoluteColorBase(AbsoluteColorBase::NamedColorOrTransparent(Ident {
span: $span,
value: name.into(),
raw: name.into(),
raw: None,
}))
} else {
let compact = get_short_hex(hex);
@ -205,7 +205,7 @@ macro_rules! make_color {
Color::AbsoluteColorBase(AbsoluteColorBase::HexColor(HexColor {
span: $span,
value: value.clone().into(),
raw: value.into(),
raw: None,
}))
}
}
@ -419,7 +419,7 @@ impl VisitMut for CompressColor {
Ident {
span: *span,
value: value.into(),
raw: value.into(),
raw: None,
},
));
}

View File

@ -198,7 +198,7 @@ impl VisitMut for CompressDeclaration {
declaration.value = vec![ComponentValue::Ident(Ident {
span: *span,
value: "inline-block".into(),
raw: "inline-block".into(),
raw: None,
})];
}
// `block flow list-item` -> `list-item`
@ -432,7 +432,7 @@ impl VisitMut for CompressDeclaration {
ComponentValue::Number(Number {
span,
value: 400.0,
raw: "400".into(),
raw: None,
})
}
ComponentValue::Ident(Ident { value, span, .. })
@ -441,7 +441,7 @@ impl VisitMut for CompressDeclaration {
ComponentValue::Number(Number {
span,
value: 700.0,
raw: "700".into(),
raw: None,
})
}
_ => node,
@ -471,14 +471,14 @@ impl VisitMut for CompressDeclaration {
declaration.value = vec![ComponentValue::Ident(Ident {
span: *span,
value: "repeat-x".into(),
raw: "repeat-x".into(),
raw: None,
})];
}
("no-repeat", "repeat") => {
declaration.value = vec![ComponentValue::Ident(Ident {
span: *span,
value: "repeat-y".into(),
raw: "repeat-y".into(),
raw: None,
})];
}
("repeat", "repeat")

View File

@ -34,31 +34,31 @@ impl VisitMut for CompressEasingFunction {
*component_value = ComponentValue::Ident(Ident {
span: *span,
value: "linear".into(),
raw: "linear".into(),
raw: None,
})
} else if *first == 0.25 && *second == 0.1 && *third == 0.25 && *fourth == 1.0 {
*component_value = ComponentValue::Ident(Ident {
span: *span,
value: "easy".into(),
raw: "easy".into(),
raw: None,
})
} else if *first == 0.42 && *second == 0.0 && *third == 1.0 && *fourth == 1.0 {
*component_value = ComponentValue::Ident(Ident {
span: *span,
value: "ease-in".into(),
raw: "ease-in".into(),
raw: None,
})
} else if *first == 0.0 && *second == 0.0 && *third == 0.58 && *fourth == 1.0 {
*component_value = ComponentValue::Ident(Ident {
span: *span,
value: "ease-out".into(),
raw: "ease-out".into(),
raw: None,
})
} else if *first == 0.42 && *second == 0.0 && *third == 0.58 && *fourth == 1.0 {
*component_value = ComponentValue::Ident(Ident {
span: *span,
value: "ease-in-out".into(),
raw: "ease-in-out".into(),
raw: None,
})
}
}
@ -82,14 +82,14 @@ impl VisitMut for CompressEasingFunction {
*component_value = ComponentValue::Ident(Ident {
span: *span,
value: "step-start".into(),
raw: "step-start".into(),
raw: None,
})
}
"end" | "jump-end" => {
*component_value = ComponentValue::Ident(Ident {
span: *span,
value: "step-end".into(),
raw: "step-end".into(),
raw: None,
})
}
_ => {}
@ -103,7 +103,7 @@ impl VisitMut for CompressEasingFunction {
function_value[2] = ComponentValue::Ident(Ident {
span: *span,
value: "start".into(),
raw: "start".into(),
raw: None,
})
}
(

View File

@ -18,12 +18,12 @@ impl VisitMut for CompressFrequency {
frequency.value = Number {
span: frequency.value.span,
value: new_value,
raw: new_value.to_string().into(),
raw: None,
};
frequency.unit = Ident {
span: frequency.unit.span,
value: "khz".into(),
raw: "khz".into(),
raw: None,
};
}
"khz"
@ -34,13 +34,13 @@ impl VisitMut for CompressFrequency {
frequency.value = Number {
value: new_value,
raw: new_value.to_string().into(),
raw: None,
span: frequency.span,
};
frequency.unit = Ident {
span: frequency.unit.span,
value: "hz".into(),
raw: "hz".into(),
raw: None,
};
}
_ => {}

View File

@ -23,7 +23,7 @@ impl VisitMut for CompressKeyframes {
KeyframesName::CustomIdent(CustomIdent {
span: string.span,
value: string.value.to_string().into(),
raw: string.raw[1..string.raw.len() - 1].to_string().into(),
raw: None,
}),
));
}
@ -41,7 +41,7 @@ impl VisitMut for CompressKeyframes {
value: Number {
span: DUMMY_SP,
value: 0.0,
raw: "0%".into(),
raw: None,
},
})
}
@ -49,7 +49,7 @@ impl VisitMut for CompressKeyframes {
*keyframe_selector = KeyframeSelector::Ident(Ident {
span: i.span,
value: "to".into(),
raw: "to".into(),
raw: None,
})
}
_ => {}

View File

@ -136,7 +136,7 @@ impl VisitMut for CompressLength {
*component_value = ComponentValue::Number(Number {
span: *span,
value: 0.0,
raw: "0".into(),
raw: None,
});
}
_ => {}
@ -157,12 +157,12 @@ impl VisitMut for CompressLength {
length.value = Number {
span: length.value.span,
value: new_value,
raw: new_value.to_string().into(),
raw: None,
};
length.unit = Ident {
span: length.unit.span,
value: "in".into(),
raw: "in".into(),
raw: None,
};
} else if value <= 0.1 {
let new_value = self.convert(value, from, "mm");
@ -170,12 +170,12 @@ impl VisitMut for CompressLength {
length.value = Number {
span: length.value.span,
value: new_value,
raw: new_value.to_string().into(),
raw: None,
};
length.unit = Ident {
span: length.unit.span,
value: "mm".into(),
raw: "mm".into(),
raw: None,
};
}
}
@ -186,12 +186,12 @@ impl VisitMut for CompressLength {
length.value = Number {
span: length.value.span,
value: new_value,
raw: new_value.to_string().into(),
raw: None,
};
length.unit = Ident {
span: length.unit.span,
value: "in".into(),
raw: "in".into(),
raw: None,
};
} else if value % 10.0 == 0.0 {
let new_value = self.convert(value, from, "cm");
@ -199,12 +199,12 @@ impl VisitMut for CompressLength {
length.value = Number {
span: length.value.span,
value: new_value,
raw: new_value.to_string().into(),
raw: None,
};
length.unit = Ident {
span: length.unit.span,
value: "cm".into(),
raw: "cm".into(),
raw: None,
};
}
}
@ -215,12 +215,12 @@ impl VisitMut for CompressLength {
length.value = Number {
span: length.value.span,
value: new_value,
raw: new_value.to_string().into(),
raw: None,
};
length.unit = Ident {
span: length.unit.span,
value: "cm".into(),
raw: "cm".into(),
raw: None,
};
} else if value % 101.6 == 0.0 {
let new_value = self.convert(value, from, "in");
@ -228,12 +228,12 @@ impl VisitMut for CompressLength {
length.value = Number {
span: length.value.span,
value: new_value,
raw: new_value.to_string().into(),
raw: None,
};
length.unit = Ident {
span: length.unit.span,
value: "in".into(),
raw: "in".into(),
raw: None,
};
}
}
@ -244,12 +244,12 @@ impl VisitMut for CompressLength {
length.value = Number {
span: length.value.span,
value: new_value,
raw: new_value.to_string().into(),
raw: None,
};
length.unit = Ident {
span: length.unit.span,
value: "in".into(),
raw: "in".into(),
raw: None,
};
}
}
@ -260,12 +260,12 @@ impl VisitMut for CompressLength {
length.value = Number {
span: length.value.span,
value: new_value,
raw: new_value.to_string().into(),
raw: None,
};
length.unit = Ident {
span: length.unit.span,
value: "in".into(),
raw: "in".into(),
raw: None,
};
} else if value % 12.0 == 0.0 {
let new_value = self.convert(value, from, "pc");
@ -273,12 +273,12 @@ impl VisitMut for CompressLength {
length.value = Number {
span: length.value.span,
value: new_value,
raw: new_value.to_string().into(),
raw: None,
};
length.unit = Ident {
span: length.unit.span,
value: "pc".into(),
raw: "pc".into(),
raw: None,
};
} else if value % 0.75 == 0.0 {
let new_value = self.convert(value, from, "px");
@ -286,12 +286,12 @@ impl VisitMut for CompressLength {
length.value = Number {
span: length.value.span,
value: new_value,
raw: new_value.to_string().into(),
raw: None,
};
length.unit = Ident {
span: length.unit.span,
value: "px".into(),
raw: "px".into(),
raw: None,
};
}
}

View File

@ -29,7 +29,7 @@ impl VisitMut for CompressSelector {
*an_plus_b = AnPlusB::Ident(Ident {
span: *span,
value: "odd".into(),
raw: "odd".into(),
raw: None,
});
}
// `2n-0`, `2n-2`, `2n-4`, etc => `2n`
@ -128,7 +128,7 @@ impl VisitMut for CompressSelector {
name: Ident {
span: DUMMY_SP,
value: "first-child".into(),
raw: "first-child".into(),
raw: None,
},
children: None,
})
@ -155,7 +155,7 @@ impl VisitMut for CompressSelector {
name: Ident {
span: DUMMY_SP,
value: "last-child".into(),
raw: "last-child".into(),
raw: None,
},
children: None,
})
@ -182,7 +182,7 @@ impl VisitMut for CompressSelector {
name: Ident {
span: DUMMY_SP,
value: "first-of-type".into(),
raw: "first-of-type".into(),
raw: None,
},
children: None,
})
@ -209,7 +209,7 @@ impl VisitMut for CompressSelector {
name: Ident {
span: DUMMY_SP,
value: "last-of-type".into(),
raw: "last-of-type".into(),
raw: None,
},
children: None,
})
@ -297,7 +297,7 @@ impl VisitMut for CompressSelector {
attribute_selector.value = Some(AttributeSelectorValue::Ident(Ident {
span: *span,
value: value.clone(),
raw: value.clone(),
raw: None,
}));
}
}

View File

@ -18,12 +18,12 @@ impl VisitMut for CompressTime {
time.value = Number {
span: time.value.span,
value: new_value,
raw: new_value.to_string().into(),
raw: None,
};
time.unit = Ident {
span: time.unit.span,
value: "s".into(),
raw: "s".into(),
raw: None,
};
}
"s" if time.value.value > 0.0 && time.value.value < 0.1 => {
@ -31,13 +31,13 @@ impl VisitMut for CompressTime {
time.value = Number {
value: new_value,
raw: new_value.to_string().into(),
raw: None,
span: time.span,
};
time.unit = Ident {
span: time.unit.span,
value: "ms".into(),
raw: "ms".into(),
raw: None,
};
}
_ => {}

View File

@ -39,7 +39,7 @@ impl VisitMut for CompressTransformFunction {
*name = Ident {
span: name.span,
value: "translateY".into(),
raw: "translateY".into(),
raw: None,
};
*function_value = vec![second.clone()];
}
@ -70,7 +70,7 @@ impl VisitMut for CompressTransformFunction {
*name = Ident {
span: name.span,
value: "translateZ".into(),
raw: "translateZ".into(),
raw: None,
};
*function_value = vec![third.clone()];
}
@ -107,7 +107,7 @@ impl VisitMut for CompressTransformFunction {
*name = Ident {
span: name.span,
value: "scaleX".into(),
raw: "scaleX".into(),
raw: None,
};
*function_value = vec![first.clone()];
}
@ -121,7 +121,7 @@ impl VisitMut for CompressTransformFunction {
*name = Ident {
span: name.span,
value: "scaleY".into(),
raw: "scaleY".into(),
raw: None,
};
*function_value = vec![second.clone()];
}
@ -152,7 +152,7 @@ impl VisitMut for CompressTransformFunction {
*name = Ident {
span: name.span,
value: "scaleX".into(),
raw: "scaleX".into(),
raw: None,
};
*function_value = vec![first.clone()];
}
@ -170,7 +170,7 @@ impl VisitMut for CompressTransformFunction {
*name = Ident {
span: name.span,
value: "scaleY".into(),
raw: "scaleY".into(),
raw: None,
};
*function_value = vec![second.clone()];
}
@ -188,7 +188,7 @@ impl VisitMut for CompressTransformFunction {
*name = Ident {
span: name.span,
value: "scaleZ".into(),
raw: "scaleZ".into(),
raw: None,
};
*function_value = vec![third.clone()];
}
@ -289,7 +289,7 @@ impl VisitMut for CompressTransformFunction {
*name = Ident {
span: name.span,
value: "matrix".into(),
raw: "matrix".into(),
raw: None,
};
*function_value = vec![
first.clone(),
@ -337,7 +337,7 @@ impl VisitMut for CompressTransformFunction {
*name = Ident {
span: name.span,
value: "rotateX".into(),
raw: "rotateX".into(),
raw: None,
};
*function_value = vec![fourth_value.clone()];
}
@ -359,7 +359,7 @@ impl VisitMut for CompressTransformFunction {
*name = Ident {
span: name.span,
value: "rotateY".into(),
raw: "rotateY".into(),
raw: None,
};
*function_value = vec![fourth_value.clone()];
}
@ -381,7 +381,7 @@ impl VisitMut for CompressTransformFunction {
*name = Ident {
span: name.span,
value: "rotate".into(),
raw: "rotate".into(),
raw: None,
};
*function_value = vec![fourth_value.clone()];
}
@ -396,7 +396,7 @@ impl VisitMut for CompressTransformFunction {
*name = Ident {
span: name.span,
value: "rotate".into(),
raw: "rotate".into(),
raw: None,
};
}
@ -416,7 +416,7 @@ impl VisitMut for CompressTransformFunction {
*name = Ident {
span: name.span,
value: "skewX".into(),
raw: "skewX".into(),
raw: None,
};
*function_value = vec![first.clone()];
}
@ -431,7 +431,7 @@ impl VisitMut for CompressTransformFunction {
*name = Ident {
span: name.span,
value: "skewY".into(),
raw: "skewY".into(),
raw: None,
};
*function_value = vec![second.clone()];
}

View File

@ -51,10 +51,10 @@ impl VisitMut for CompressUrl {
url.value = Some(UrlValue::Raw(UrlValueRaw {
span: *span,
before: "".into(),
after: "".into(),
value: escaped.clone().into(),
raw: escaped.clone().into(),
before: None,
raw: None,
after: None,
}));
}
}

View File

@ -32,7 +32,7 @@ where
Default::default(),
),
value: at_keyword_name.0,
raw: at_keyword_name.1,
raw: Some(at_keyword_name.1),
})
} else {
AtRuleName::Ident(Ident {
@ -42,7 +42,7 @@ where
Default::default(),
),
value: at_keyword_name.0,
raw: at_keyword_name.1,
raw: Some(at_keyword_name.1),
})
};
let mut at_rule = AtRule {
@ -719,7 +719,7 @@ where
if &*custom_ident.value.to_ascii_lowercase() == "none" {
return Err(Error::new(
custom_ident.span,
ErrorKind::InvalidCustomIdent(custom_ident.raw),
ErrorKind::InvalidCustomIdent(custom_ident.value),
));
}
@ -1785,7 +1785,11 @@ where
let span = self.input.cur_span()?;
let token = bump!(self);
let ident = match token {
Token::Ident { value, raw } => Ident { span, value, raw },
Token::Ident { value, raw } => Ident {
span,
value,
raw: Some(raw),
},
_ => {
unreachable!();
}

View File

@ -393,7 +393,11 @@ where
let value: JsWord = "*".into();
let raw = value.clone();
prefix = Some(Ident { span, value, raw });
prefix = Some(Ident {
span,
value,
raw: Some(raw),
});
}
expect!(self, "|");
@ -486,7 +490,11 @@ where
));
}
Ident { span, value, raw }
Ident {
span,
value,
raw: Some(raw),
}
}
_ => {
unreachable!()
@ -875,7 +883,7 @@ where
name: Ident {
span: Span::new(fn_span.lo, fn_span.hi - BytePos(1), Default::default()),
value: names.0,
raw: names.1,
raw: Some(names.1),
},
children: Some(children),
})
@ -985,7 +993,7 @@ where
name: Ident {
span: Span::new(fn_span.lo, fn_span.hi - BytePos(1), Default::default()),
value: names.0,
raw: names.1,
raw: Some(names.1),
},
children: Some(children),
})

View File

@ -1360,7 +1360,7 @@ where
Ok(Integer {
span,
value: value.round() as i64,
raw,
raw: Some(raw),
})
}
_ => {
@ -1384,7 +1384,11 @@ where
let value = bump!(self);
match value {
Token::Number { value, raw, .. } => Ok(Number { span, value, raw }),
Token::Number { value, raw, .. } => Ok(Number {
span,
value,
raw: Some(raw),
}),
_ => {
unreachable!()
}
@ -1412,7 +1416,11 @@ where
_ => {}
}
Ok(CustomIdent { span, value, raw })
Ok(CustomIdent {
span,
value,
raw: Some(raw),
})
}
_ => {
unreachable!()
@ -1441,7 +1449,11 @@ where
));
}
Ok(DashedIdent { span, value, raw })
Ok(DashedIdent {
span,
value,
raw: Some(raw),
})
}
_ => {
unreachable!()
@ -1475,7 +1487,11 @@ where
));
}
Ok(CustomPropertyName { span, value, raw })
Ok(CustomPropertyName {
span,
value,
raw: Some(raw),
})
}
_ => {
unreachable!()
@ -1496,7 +1512,11 @@ where
}
match bump!(self) {
Token::Ident { value, raw } => Ok(Ident { span, value, raw }),
Token::Ident { value, raw } => Ok(Ident {
span,
value,
raw: Some(raw),
}),
_ => {
unreachable!()
}
@ -1566,13 +1586,13 @@ where
Ok(Length {
span,
value: Number {
value,
raw: raw_value,
span: swc_common::Span::new(
span.lo,
span.hi - BytePos(unit_len),
Default::default(),
),
value,
raw: Some(raw_value),
},
unit: Ident {
span: swc_common::Span::new(
@ -1581,7 +1601,7 @@ where
Default::default(),
),
value: unit,
raw: raw_unit,
raw: Some(raw_unit),
},
})
}
@ -1623,13 +1643,13 @@ where
Ok(Angle {
span,
value: Number {
value,
raw: raw_value,
span: swc_common::Span::new(
span.lo,
span.hi - BytePos(unit_len),
Default::default(),
),
value,
raw: Some(raw_value),
},
unit: Ident {
span: swc_common::Span::new(
@ -1638,7 +1658,7 @@ where
Default::default(),
),
value: unit,
raw: raw_unit,
raw: Some(raw_unit),
},
})
}
@ -1677,13 +1697,13 @@ where
Ok(Time {
span,
value: Number {
value,
raw: raw_value,
span: swc_common::Span::new(
span.lo,
span.hi - BytePos(unit_len),
Default::default(),
),
value,
raw: Some(raw_value),
},
unit: Ident {
span: swc_common::Span::new(
@ -1692,7 +1712,7 @@ where
Default::default(),
),
value: unit,
raw: raw_unit,
raw: Some(raw_unit),
},
})
}
@ -1731,13 +1751,13 @@ where
Ok(Frequency {
span,
value: Number {
value,
raw: raw_value,
span: swc_common::Span::new(
span.lo,
span.hi - BytePos(unit_len),
Default::default(),
),
value,
raw: Some(raw_value),
},
unit: Ident {
span: swc_common::Span::new(
@ -1746,7 +1766,7 @@ where
Default::default(),
),
value: unit,
raw: raw_unit,
raw: Some(raw_unit),
},
})
}
@ -1788,13 +1808,13 @@ where
Ok(Resolution {
span,
value: Number {
value,
raw: raw_value,
span: swc_common::Span::new(
span.lo,
span.hi - BytePos(unit_len),
Default::default(),
),
value,
raw: Some(raw_value),
},
unit: Ident {
span: swc_common::Span::new(
@ -1803,7 +1823,7 @@ where
Default::default(),
),
value: unit,
raw: raw_unit,
raw: Some(raw_unit),
},
})
}
@ -1842,13 +1862,13 @@ where
Ok(Flex {
span,
value: Number {
value,
raw: raw_value,
span: swc_common::Span::new(
span.lo,
span.hi - BytePos(unit_len),
Default::default(),
),
value,
raw: Some(raw_value),
},
unit: Ident {
span: swc_common::Span::new(
@ -1857,7 +1877,7 @@ where
Default::default(),
),
value: unit,
raw: raw_unit,
raw: Some(raw_unit),
},
})
}
@ -1892,13 +1912,13 @@ where
Ok(UnknownDimension {
span,
value: Number {
value,
raw: raw_value,
span: swc_common::Span::new(
span.lo,
span.hi - BytePos(unit_len),
Default::default(),
),
value,
raw: Some(raw_value),
},
unit: Ident {
span: swc_common::Span::new(
@ -1907,7 +1927,7 @@ where
Default::default(),
),
value: unit,
raw: raw_unit,
raw: Some(raw_unit),
},
})
}
@ -2003,7 +2023,11 @@ where
}
match bump!(self) {
Token::Hash { value, raw, .. } => Ok(HexColor { span, value, raw }),
Token::Hash { value, raw, .. } => Ok(HexColor {
span,
value,
raw: Some(raw),
}),
_ => {
unreachable!()
}
@ -2108,7 +2132,7 @@ where
let value = Number {
span: swc_common::Span::new(span.lo, span.hi - BytePos(1), Default::default()),
value,
raw,
raw: Some(raw),
};
Ok(Percentage { span, value })
@ -2132,7 +2156,11 @@ where
}
match bump!(self) {
Token::String { value, raw } => Ok(Str { span, value, raw }),
Token::String { value, raw } => Ok(Str {
span,
value,
raw: Some(raw),
}),
_ => {
unreachable!()
}
@ -2171,7 +2199,7 @@ where
Default::default(),
),
value: name,
raw: raw_name,
raw: Some(raw_name),
};
let value = Some(UrlValue::Raw(UrlValueRaw {
span: swc_common::Span::new(
@ -2179,10 +2207,10 @@ where
span.hi - BytePos(1),
Default::default(),
),
before,
after,
value,
raw: raw_value,
before: Some(before),
raw: Some(raw_value),
after: Some(after),
}));
Ok(Url {
@ -2208,7 +2236,7 @@ where
let name = Ident {
span: swc_common::Span::new(span.lo, span.hi - BytePos(1), Default::default()),
value: function_name,
raw: raw_function_name,
raw: Some(raw_function_name),
};
self.input.skip_ws()?;
@ -2276,7 +2304,7 @@ where
let name = Ident {
span: swc_common::Span::new(span.lo, span.hi - BytePos(1), Default::default()),
value: ident.0,
raw: ident.1,
raw: Some(ident.1),
};
// Create a function with its name equal to the value of the current input token

View File

@ -556,10 +556,10 @@
"end": 340,
"ctxt": 0
},
"before": "",
"after": "",
"value": "https://www.example.com/",
"raw": "https://www.example.com/"
"before": "",
"raw": "https://www.example.com/",
"after": ""
},
"modifiers": null
}

View File

@ -172,10 +172,10 @@
"end": 80,
"ctxt": 0
},
"before": "",
"after": "",
"value": "./style.css",
"raw": "./style.css"
"before": "",
"raw": "./style.css",
"after": ""
},
"modifiers": null
},
@ -372,10 +372,10 @@
"end": 180,
"ctxt": 0
},
"before": "",
"after": "",
"value": "./style.css",
"raw": "./style.css"
"before": "",
"raw": "./style.css",
"after": ""
},
"modifiers": null
},
@ -1677,10 +1677,10 @@
"end": 850,
"ctxt": 0
},
"before": "",
"after": "",
"value": "test.css",
"raw": "test.css"
"before": "",
"raw": "test.css",
"after": ""
},
"modifiers": null
},
@ -1856,10 +1856,10 @@
"end": 923,
"ctxt": 0
},
"before": "",
"after": "",
"value": "test.css",
"raw": "test.css"
"before": "",
"raw": "test.css",
"after": ""
},
"modifiers": null
},
@ -1917,10 +1917,10 @@
"end": 946,
"ctxt": 0
},
"before": "",
"after": "",
"value": "test.css",
"raw": "test.css"
"before": "",
"raw": "test.css",
"after": ""
},
"modifiers": null
},
@ -1978,10 +1978,10 @@
"end": 970,
"ctxt": 0
},
"before": "",
"after": " ",
"value": "test.css",
"raw": "test.css"
"before": "",
"raw": "test.css",
"after": " "
},
"modifiers": null
},
@ -2039,10 +2039,10 @@
"end": 994,
"ctxt": 0
},
"before": " ",
"after": "",
"value": "test.css",
"raw": "test.css"
"before": " ",
"raw": "test.css",
"after": ""
},
"modifiers": null
},
@ -2100,10 +2100,10 @@
"end": 1019,
"ctxt": 0
},
"before": " ",
"after": " ",
"value": "test.css",
"raw": "test.css"
"before": " ",
"raw": "test.css",
"after": " "
},
"modifiers": null
},
@ -2161,10 +2161,10 @@
"end": 1044,
"ctxt": 0
},
"before": "\n",
"after": "\n",
"value": "test.css",
"raw": "test.css"
"before": "\n",
"raw": "test.css",
"after": "\n"
},
"modifiers": null
},
@ -2222,10 +2222,10 @@
"end": 1059,
"ctxt": 0
},
"before": "",
"after": "",
"value": "",
"raw": ""
"before": "",
"raw": "",
"after": ""
},
"modifiers": null
},
@ -2641,10 +2641,10 @@
"end": 1201,
"ctxt": 0
},
"before": "",
"after": "",
"value": "",
"raw": ""
"before": "",
"raw": "",
"after": ""
},
"modifiers": null
},
@ -2820,10 +2820,10 @@
"end": 1258,
"ctxt": 0
},
"before": "",
"after": "",
"value": "test.css",
"raw": "test.css"
"before": "",
"raw": "test.css",
"after": ""
},
"modifiers": null
},
@ -2957,10 +2957,10 @@
"end": 1316,
"ctxt": 0
},
"before": "",
"after": "",
"value": "test.css",
"raw": "test.css"
"before": "",
"raw": "test.css",
"after": ""
},
"modifiers": null
},
@ -3094,10 +3094,10 @@
"end": 1375,
"ctxt": 0
},
"before": "",
"after": "",
"value": "test.css",
"raw": "test.css"
"before": "",
"raw": "test.css",
"after": ""
},
"modifiers": null
},
@ -3231,10 +3231,10 @@
"end": 1432,
"ctxt": 0
},
"before": "",
"after": "",
"value": "test.css",
"raw": "test.css"
"before": "",
"raw": "test.css",
"after": ""
},
"modifiers": null
},
@ -3368,10 +3368,10 @@
"end": 1511,
"ctxt": 0
},
"before": "",
"after": "",
"value": "test.css",
"raw": "test.css"
"before": "",
"raw": "test.css",
"after": ""
},
"modifiers": null
},
@ -3564,10 +3564,10 @@
"end": 1618,
"ctxt": 0
},
"before": "",
"after": "",
"value": "~package/test.css",
"raw": "~package/test.css"
"before": "",
"raw": "~package/test.css",
"after": ""
},
"modifiers": null
},
@ -3920,10 +3920,10 @@
"end": 1933,
"ctxt": 0
},
"before": "",
"after": "",
"value": "~package/tilde.css",
"raw": "~package/tilde.css"
"before": "",
"raw": "~package/tilde.css",
"after": ""
},
"modifiers": null
},
@ -3981,10 +3981,10 @@
"end": 1972,
"ctxt": 0
},
"before": "",
"after": "",
"value": "~aliasesImport/alias.css",
"raw": "~aliasesImport/alias.css"
"before": "",
"raw": "~aliasesImport/alias.css",
"after": ""
},
"modifiers": null
},
@ -4101,10 +4101,10 @@
"end": 2024,
"ctxt": 0
},
"before": "",
"after": "",
"value": "./test.css",
"raw": "./test.css"
"before": "",
"raw": "./test.css",
"after": ""
},
"modifiers": null
},
@ -5053,10 +5053,10 @@
"end": 2584,
"ctxt": 0
},
"before": "",
"after": "",
"value": "./test test.css",
"raw": "./test\\ test.css"
"before": "",
"raw": "./test\\ test.css",
"after": ""
},
"modifiers": null
},
@ -5114,10 +5114,10 @@
"end": 2618,
"ctxt": 0
},
"before": "",
"after": "",
"value": "./test%20test.css",
"raw": "./t\\65st%20test.css"
"before": "",
"raw": "./t\\65st%20test.css",
"after": ""
},
"modifiers": null
},
@ -5373,10 +5373,10 @@
"end": 2814,
"ctxt": 0
},
"before": " ",
"after": " ",
"value": "test.css",
"raw": "test.css"
"before": " ",
"raw": "test.css",
"after": " "
},
"modifiers": null
},
@ -5533,10 +5533,10 @@
"end": 2947,
"ctxt": 0
},
"before": "",
"after": "",
"value": "test.css?foo=bar",
"raw": "test.css?foo=bar"
"before": "",
"raw": "test.css?foo=bar",
"after": ""
},
"modifiers": null
},
@ -5594,10 +5594,10 @@
"end": 2983,
"ctxt": 0
},
"before": "",
"after": "",
"value": "test.css?foo=bar#hash",
"raw": "test.css?foo=bar#hash"
"before": "",
"raw": "test.css?foo=bar#hash",
"after": ""
},
"modifiers": null
},
@ -5655,10 +5655,10 @@
"end": 3012,
"ctxt": 0
},
"before": "",
"after": "",
"value": "test.css?#hash",
"raw": "test.css?#hash"
"before": "",
"raw": "test.css?#hash",
"after": ""
},
"modifiers": null
},
@ -6177,10 +6177,10 @@
"end": 3305,
"ctxt": 0
},
"before": " ",
"after": " ",
"value": "./test.css",
"raw": "./test.css"
"before": " ",
"raw": "./test.css",
"after": " "
},
"modifiers": null
},
@ -6455,10 +6455,10 @@
"end": 3639,
"ctxt": 0
},
"before": "",
"after": "",
"value": "data:text/css;charset=utf-8,a%20%7B%0D%0A%20%20color%3A%20red%3B%0D%0A%7D",
"raw": "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": ""
},
"modifiers": null
},
@ -6516,10 +6516,10 @@
"end": 3672,
"ctxt": 0
},
"before": "",
"after": "",
"value": "package/first.css",
"raw": "package/first.css"
"before": "",
"raw": "package/first.css",
"after": ""
},
"modifiers": null
},
@ -6577,10 +6577,10 @@
"end": 3705,
"ctxt": 0
},
"before": "",
"after": "",
"value": "package/second.css",
"raw": "package/second.css"
"before": "",
"raw": "package/second.css",
"after": ""
},
"modifiers": null
},
@ -9038,10 +9038,10 @@
"end": 5196,
"ctxt": 0
},
"before": "",
"after": "",
"value": "test.css",
"raw": "test.css"
"before": "",
"raw": "test.css",
"after": ""
},
"modifiers": null
},
@ -9099,10 +9099,10 @@
"end": 5247,
"ctxt": 0
},
"before": "",
"after": "",
"value": "test.css",
"raw": "test.css"
"before": "",
"raw": "test.css",
"after": ""
},
"modifiers": null
},
@ -9160,10 +9160,10 @@
"end": 5284,
"ctxt": 0
},
"before": "",
"after": "",
"value": "test.css",
"raw": "test.css"
"before": "",
"raw": "test.css",
"after": ""
},
"modifiers": null
},
@ -9297,10 +9297,10 @@
"end": 5369,
"ctxt": 0
},
"before": "",
"after": "",
"value": "test.css",
"raw": "test.css"
"before": "",
"raw": "test.css",
"after": ""
},
"modifiers": null
},

View File

@ -140,10 +140,10 @@
"end": 80,
"ctxt": 0
},
"before": "",
"after": "",
"value": "http://www.w3.org/1999/xhtml",
"raw": "http://www.w3.org/1999/xhtml"
"before": "",
"raw": "http://www.w3.org/1999/xhtml",
"after": ""
},
"modifiers": null
}
@ -265,10 +265,10 @@
"end": 176,
"ctxt": 0
},
"before": "",
"after": "",
"value": "http://www.w3.org/2000/svg",
"raw": "http://www.w3.org/2000/svg"
"before": "",
"raw": "http://www.w3.org/2000/svg",
"after": ""
},
"modifiers": null
}

View File

@ -1794,10 +1794,10 @@
"end": 613,
"ctxt": 0
},
"before": "",
"after": "",
"value": "path/to.png",
"raw": "path/to.png"
"before": "",
"raw": "path/to.png",
"after": ""
},
"modifiers": null
},

View File

@ -749,10 +749,10 @@
"end": 315,
"ctxt": 0
},
"before": "",
"after": "",
"value": "value",
"raw": "value"
"before": "",
"raw": "value",
"after": ""
},
"modifiers": null
},
@ -780,10 +780,10 @@
"end": 325,
"ctxt": 0
},
"before": "",
"after": "",
"value": "value",
"raw": "value"
"before": "",
"raw": "value",
"after": ""
},
"modifiers": null
}

View File

@ -121,10 +121,10 @@
"end": 21,
"ctxt": 0
},
"before": "",
"after": "",
"value": "aج",
"raw": "a\\62c"
"before": "",
"raw": "a\\62c",
"after": ""
},
"modifiers": null
}

View File

@ -54,10 +54,10 @@
"end": 20,
"ctxt": 0
},
"before": "",
"after": "",
"value": "foo.css",
"raw": "foo.css"
"before": "",
"raw": "foo.css",
"after": ""
},
"modifiers": null
},

View File

@ -121,10 +121,10 @@
"end": 22,
"ctxt": 0
},
"before": "",
"after": "",
"value": "abc",
"raw": "a\\62 c"
"before": "",
"raw": "a\\62 c",
"after": ""
},
"modifiers": null
}

View File

@ -121,10 +121,10 @@
"end": 18,
"ctxt": 0
},
"before": "",
"after": "",
"value": ",",
"raw": "\\,"
"before": "",
"raw": "\\,",
"after": ""
},
"modifiers": null
}

View File

@ -54,10 +54,10 @@
"end": 20,
"ctxt": 0
},
"before": "",
"after": "",
"value": "foo.css",
"raw": "foo.css"
"before": "",
"raw": "foo.css",
"after": ""
},
"modifiers": null
},

View File

@ -121,10 +121,10 @@
"end": 19,
"ctxt": 0
},
"before": "",
"after": "",
"value": ",",
"raw": "\\2c"
"before": "",
"raw": "\\2c",
"after": ""
},
"modifiers": null
}

View File

@ -121,10 +121,10 @@
"end": 22,
"ctxt": 0
},
"before": "",
"after": "",
"value": "abc",
"raw": "\\61 bc"
"before": "",
"raw": "\\61 bc",
"after": ""
},
"modifiers": null
}

View File

@ -54,10 +54,10 @@
"end": 13,
"ctxt": 0
},
"before": "",
"after": "",
"value": "",
"raw": ""
"before": "",
"raw": "",
"after": ""
},
"modifiers": null
},

View File

@ -121,10 +121,10 @@
"end": 21,
"ctxt": 0
},
"before": "",
"after": "",
"value": "憼",
"raw": "\\61bc"
"before": "",
"raw": "\\61bc",
"after": ""
},
"modifiers": null
}

View File

@ -121,10 +121,10 @@
"end": 109,
"ctxt": 0
},
"before": "",
"after": "",
"value": "data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7",
"raw": "data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7"
"before": "",
"raw": "data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7",
"after": ""
},
"modifiers": null
}
@ -523,10 +523,10 @@
"end": 488,
"ctxt": 0
},
"before": "",
"after": "",
"value": "",
"raw": ""
"before": "",
"raw": "",
"after": ""
},
"modifiers": null
}
@ -575,10 +575,10 @@
"end": 520,
"ctxt": 0
},
"before": " ",
"after": "",
"value": "",
"raw": ""
"before": " ",
"raw": "",
"after": ""
},
"modifiers": null
}
@ -877,10 +877,10 @@
"end": 734,
"ctxt": 0
},
"before": "",
"after": "",
"value": "./image.png",
"raw": "./image.png"
"before": "",
"raw": "./image.png",
"after": ""
},
"modifiers": null
}
@ -929,10 +929,10 @@
"end": 780,
"ctxt": 0
},
"before": " ",
"after": " ",
"value": "./image.png",
"raw": "./image.png"
"before": " ",
"raw": "./image.png",
"after": " "
},
"modifiers": null
}
@ -981,10 +981,10 @@
"end": 829,
"ctxt": 0
},
"before": " ",
"after": " ",
"value": "./image2.png",
"raw": "./image\\32.png"
"before": " ",
"raw": "./image\\32.png",
"after": " "
},
"modifiers": null
}
@ -1033,10 +1033,10 @@
"end": 888,
"ctxt": 0
},
"before": " \n ",
"after": " \n ",
"value": "./image2.png",
"raw": "./image\\32.png"
"before": " \n ",
"raw": "./image\\32.png",
"after": " \n "
},
"modifiers": null
}
@ -1085,10 +1085,10 @@
"end": 974,
"ctxt": 0
},
"before": "\n \n \n \n ",
"after": "\n \n \n \n ",
"value": "./image2.png",
"raw": "./image\\32.png"
"before": "\n \n \n \n ",
"raw": "./image\\32.png",
"after": "\n \n \n \n "
},
"modifiers": null
}
@ -1137,10 +1137,10 @@
"end": 1039,
"ctxt": 0
},
"before": " \n\n\n\n ",
"after": "\n\n\n\n ",
"value": "./image2.png",
"raw": "./image\\32.png"
"before": " \n\n\n\n ",
"raw": "./image\\32.png",
"after": "\n\n\n\n "
},
"modifiers": null
}
@ -1189,10 +1189,10 @@
"end": 1076,
"ctxt": 0
},
"before": "",
"after": "",
"value": "image.png\u0001",
"raw": "image.png\\0001"
"before": "",
"raw": "image.png\\0001",
"after": ""
},
"modifiers": null
}
@ -1241,10 +1241,10 @@
"end": 1110,
"ctxt": 0
},
"before": "",
"after": "",
"value": "image.png\u0001",
"raw": "image.png\\1"
"before": "",
"raw": "image.png\\1",
"after": ""
},
"modifiers": null
}
@ -1293,10 +1293,10 @@
"end": 1147,
"ctxt": 0
},
"before": "",
"after": "",
"value": "image.png힙",
"raw": "image.png\\D799"
"before": "",
"raw": "image.png\\D799",
"after": ""
},
"modifiers": null
}
@ -1345,10 +1345,10 @@
"end": 1184,
"ctxt": 0
},
"before": "",
"after": "",
"value": "image.png",
"raw": "image.png\\E000"
"before": "",
"raw": "image.png\\E000",
"after": ""
},
"modifiers": null
}
@ -1397,10 +1397,10 @@
"end": 1223,
"ctxt": 0
},
"before": "",
"after": "",
"value": "image.png􏿿",
"raw": "image.png\\10FFFF"
"before": "",
"raw": "image.png\\10FFFF",
"after": ""
},
"modifiers": null
}
@ -1449,10 +1449,10 @@
"end": 1248,
"ctxt": 0
},
"before": "",
"after": "",
"value": "18",
"raw": "18"
"before": "",
"raw": "18",
"after": ""
},
"modifiers": null
}

View File

@ -139,10 +139,10 @@
"end": 38,
"ctxt": 0
},
"before": "",
"after": "",
"value": "foo.jpg",
"raw": "foo.jpg"
"before": "",
"raw": "foo.jpg",
"after": ""
},
"modifiers": null
},

View File

@ -121,10 +121,10 @@
"end": 56,
"ctxt": 0
},
"before": "",
"after": "",
"value": "https://example.com/image.png",
"raw": "https://example.com/image.png"
"before": "",
"raw": "https://example.com/image.png",
"after": ""
},
"modifiers": null
}
@ -173,10 +173,10 @@
"end": 108,
"ctxt": 0
},
"before": "",
"after": "",
"value": "https://example.com/image.png",
"raw": "https://example.com/image.png"
"before": "",
"raw": "https://example.com/image.png",
"after": ""
},
"modifiers": null
}
@ -225,10 +225,10 @@
"end": 161,
"ctxt": 0
},
"before": "",
"after": "",
"value": "https://example.com/image.png",
"raw": "https://example.com/image.png"
"before": "",
"raw": "https://example.com/image.png",
"after": ""
},
"modifiers": null
}
@ -477,10 +477,10 @@
"end": 429,
"ctxt": 0
},
"before": "",
"after": "",
"value": "data:image/png;base64,iRxVB0",
"raw": "data:image/png;base64,iRxVB0"
"before": "",
"raw": "data:image/png;base64,iRxVB0",
"after": ""
},
"modifiers": null
}
@ -529,10 +529,10 @@
"end": 464,
"ctxt": 0
},
"before": "",
"after": "",
"value": "#IDofSVGpath",
"raw": "#IDofSVGpath"
"before": "",
"raw": "#IDofSVGpath",
"after": ""
},
"modifiers": null
}
@ -864,10 +864,10 @@
"end": 766,
"ctxt": 0
},
"before": "",
"after": "",
"value": "",
"raw": ""
"before": "",
"raw": "",
"after": ""
},
"modifiers": null
}
@ -1223,10 +1223,10 @@
"end": 1076,
"ctxt": 0
},
"before": " ",
"after": " ",
"value": "https://example.com/image.png",
"raw": "https://example.com/image.png"
"before": " ",
"raw": "https://example.com/image.png",
"after": " "
},
"modifiers": null
}
@ -1275,10 +1275,10 @@
"end": 1135,
"ctxt": 0
},
"before": " ",
"after": " ",
"value": "https://example.com/image.png",
"raw": "https://example.com/image.png"
"before": " ",
"raw": "https://example.com/image.png",
"after": " "
},
"modifiers": null
}
@ -1327,10 +1327,10 @@
"end": 1219,
"ctxt": 0
},
"before": " \n ",
"after": " \n ",
"value": "https://example.com/image.png",
"raw": "https://example.com/image.png"
"before": " \n ",
"raw": "https://example.com/image.png",
"after": " \n "
},
"modifiers": null
}
@ -1379,10 +1379,10 @@
"end": 1277,
"ctxt": 0
},
"before": "\n\n\n",
"after": "\n\n\n",
"value": "https://example.com/image.png",
"raw": "https://example.com/image.png"
"before": "\n\n\n",
"raw": "https://example.com/image.png",
"after": "\n\n\n"
},
"modifiers": null
}
@ -1431,10 +1431,10 @@
"end": 1331,
"ctxt": 0
},
"before": "",
"after": "",
"value": "https://example.com/ima)ge.png",
"raw": "https://example.com/ima\\)ge.png"
"before": "",
"raw": "https://example.com/ima\\)ge.png",
"after": ""
},
"modifiers": null
}

View File

@ -221,10 +221,10 @@
"end": 125,
"ctxt": 0
},
"before": "",
"after": "",
"value": "image.png<6E>",
"raw": "image.png\\999999"
"before": "",
"raw": "image.png\\999999",
"after": ""
},
"modifiers": null
}
@ -273,10 +273,10 @@
"end": 159,
"ctxt": 0
},
"before": "",
"after": "",
"value": "image.png<6E>",
"raw": "image.png\\0"
"before": "",
"raw": "image.png\\0",
"after": ""
},
"modifiers": null
}
@ -325,10 +325,10 @@
"end": 196,
"ctxt": 0
},
"before": "",
"after": "",
"value": "image.png<6E>",
"raw": "image.png\\D800"
"before": "",
"raw": "image.png\\D800",
"after": ""
},
"modifiers": null
}
@ -377,10 +377,10 @@
"end": 233,
"ctxt": 0
},
"before": "",
"after": "",
"value": "image.png<6E>",
"raw": "image.png\\DFFF"
"before": "",
"raw": "image.png\\DFFF",
"after": ""
},
"modifiers": null
}
@ -429,10 +429,10 @@
"end": 272,
"ctxt": 0
},
"before": "",
"after": "",
"value": "image.png<6E>",
"raw": "image.png\\11FFFF"
"before": "",
"raw": "image.png\\11FFFF",
"after": ""
},
"modifiers": null
}

View File

@ -121,10 +121,10 @@
"end": 21,
"ctxt": 0
},
"before": "",
"after": "",
"value": "foo.png",
"raw": "foo.png"
"before": "",
"raw": "foo.png",
"after": ""
},
"modifiers": null
}

View File

@ -109,14 +109,14 @@ impl VisitMut for CrossFadeFunctionReplacerOnLegacyVariant<'_> {
ComponentValue::Number(Number {
span: DUMMY_SP,
value: transparency_value,
raw: transparency_value.to_string().into(),
raw: None,
}),
]);
n.value = new_value;
n.name.value = self.to.into();
n.name.raw = self.to.into();
n.name.raw = None;
}
}
}
@ -142,18 +142,18 @@ impl VisitMut for ImageSetFunctionReplacerOnLegacyVariant<'_> {
return;
}
if let ComponentValue::Str(Str { value, raw, span }) = n {
if let ComponentValue::Str(Str { span, value, .. }) = n {
*n = ComponentValue::Url(Url {
span: *span,
name: Ident {
span: DUMMY_SP,
value: "url".into(),
raw: "url".into(),
raw: None,
},
value: Some(UrlValue::Str(Str {
span: DUMMY_SP,
value: value.as_ref().into(),
raw: raw.as_ref().into(),
raw: None,
})),
modifiers: Some(vec![]),
})
@ -169,7 +169,7 @@ impl VisitMut for ImageSetFunctionReplacerOnLegacyVariant<'_> {
if &*n.name.value.to_lowercase() == self.from {
n.name.value = self.to.into();
n.name.raw = self.to.into();
n.name.raw = None;
}
self.in_function = old_in_function;
@ -200,7 +200,7 @@ impl VisitMut for LinearGradientFunctionReplacerOnLegacyVariant<'_> {
if &*n.name.value.to_lowercase() == self.from {
n.name.value = self.to.into();
n.name.raw = self.to.into();
n.name.raw = None;
let first = n.value.get(0);
@ -239,12 +239,12 @@ impl VisitMut for LinearGradientFunctionReplacerOnLegacyVariant<'_> {
ComponentValue::Ident(Ident {
span: *first_span,
value: new_first_direction.into(),
raw: new_first_direction.into(),
raw: None,
}),
ComponentValue::Ident(Ident {
span: *second_span,
value: new_second_direction.into(),
raw: new_second_direction.into(),
raw: None,
}),
];
@ -256,7 +256,7 @@ impl VisitMut for LinearGradientFunctionReplacerOnLegacyVariant<'_> {
let new_value = vec![ComponentValue::Ident(Ident {
span: *span,
value: new_direction.into(),
raw: new_direction.into(),
raw: None,
})];
n.value.splice(0..2, new_value);
@ -285,25 +285,25 @@ impl VisitMut for LinearGradientFunctionReplacerOnLegacyVariant<'_> {
n.value[0] = ComponentValue::Ident(Ident {
span: *span,
value: "bottom".into(),
raw: "bottom".into(),
raw: None,
});
} else if angle == 90.0 {
n.value[0] = ComponentValue::Ident(Ident {
span: *span,
value: "left".into(),
raw: "left".into(),
raw: None,
});
} else if angle == 180.0 {
n.value[0] = ComponentValue::Ident(Ident {
span: *span,
value: "top".into(),
raw: "top".into(),
raw: None,
});
} else if angle == 270.0 {
n.value[0] = ComponentValue::Ident(Ident {
span: *span,
value: "right".into(),
raw: "right".into(),
raw: None,
});
} else {
let new_value = ((450.0 - angle).abs() % 360.0 * 1000.0).round() / 1000.0;
@ -313,12 +313,12 @@ impl VisitMut for LinearGradientFunctionReplacerOnLegacyVariant<'_> {
value: Number {
span: value.span,
value: new_value,
raw: new_value.to_string().into(),
raw: None,
},
unit: Ident {
span: unit.span,
value: "deg".into(),
raw: "deg".into(),
raw: None,
},
}));
}
@ -394,7 +394,7 @@ impl VisitMut for MediaFeatureResolutionReplacerOnLegacyVariant<'_> {
n.name = MediaFeatureName::Ident(Ident {
span: *feature_name_span,
value: self.to.into(),
raw: self.to.into(),
raw: None,
});
let left = match &*resolution_unit.value.to_lowercase() {
@ -408,7 +408,7 @@ impl VisitMut for MediaFeatureResolutionReplacerOnLegacyVariant<'_> {
left: Number {
span: resolution_value.span,
value: left,
raw: left.to_string().into(),
raw: None,
},
right: None,
});
@ -429,7 +429,7 @@ macro_rules! str_to_ident {
ComponentValue::Ident(Ident {
span: DUMMY_SP,
value: $val.into(),
raw: $val.into(),
raw: None,
})
}};
}
@ -499,7 +499,7 @@ impl VisitMut for Prefixer {
name: AtRuleName::Ident(Ident {
span: DUMMY_SP,
value: "-ms-viewport".into(),
raw: "-ms-viewport".into(),
raw: None,
}),
prelude: n.prelude.clone(),
block: original_simple_block.clone(),
@ -510,7 +510,7 @@ impl VisitMut for Prefixer {
name: AtRuleName::Ident(Ident {
span: DUMMY_SP,
value: "-o-viewport".into(),
raw: "-o-viewport".into(),
raw: None,
}),
prelude: n.prelude.clone(),
block: original_simple_block,
@ -534,7 +534,7 @@ impl VisitMut for Prefixer {
name: AtRuleName::Ident(Ident {
span: DUMMY_SP,
value: "-webkit-keyframes".into(),
raw: "-webkit-keyframes".into(),
raw: None,
}),
prelude: n.prelude.clone(),
block: original_simple_block.clone(),
@ -545,7 +545,7 @@ impl VisitMut for Prefixer {
name: AtRuleName::Ident(Ident {
span: DUMMY_SP,
value: "-moz-keyframes".into(),
raw: "-moz-keyframes".into(),
raw: None,
}),
prelude: n.prelude.clone(),
block: original_simple_block.clone(),
@ -556,7 +556,7 @@ impl VisitMut for Prefixer {
name: AtRuleName::Ident(Ident {
span: DUMMY_SP,
value: "-o-keyframes".into(),
raw: "-o-keyframes".into(),
raw: None,
}),
prelude: n.prelude.clone(),
block: original_simple_block,
@ -1111,7 +1111,7 @@ impl VisitMut for Prefixer {
let name = DeclarationName::Ident(Ident {
span: DUMMY_SP,
value: $name.into(),
raw: $name.into(),
raw: None,
});
let new_value = match $prefix {
Prefix::Webkit => webkit_value.clone(),
@ -1139,7 +1139,7 @@ impl VisitMut for Prefixer {
let name = DeclarationName::Ident(Ident {
span: DUMMY_SP,
value: $name.into(),
raw: $name.into(),
raw: None,
});
self.added_declarations.push(Declaration {
@ -1370,7 +1370,7 @@ impl VisitMut for Prefixer {
Some(ComponentValue::Integer(Integer {
span: *span,
value: 0,
raw: "0".into(),
raw: None,
}))
}
Some(ComponentValue::Ident(Ident { value, span, .. }))
@ -1379,7 +1379,7 @@ impl VisitMut for Prefixer {
Some(ComponentValue::Integer(Integer {
span: *span,
value: 1,
raw: "1".into(),
raw: None,
}))
}
Some(any) => Some(any.clone()),
@ -1415,12 +1415,12 @@ impl VisitMut for Prefixer {
value: Number {
span: DUMMY_SP,
value: 0.0,
raw: "0".into(),
raw: None,
},
unit: Ident {
span: DUMMY_SP,
value: "px".into(),
raw: "px".into(),
raw: None,
},
}));
}

View File

@ -3,43 +3,43 @@ a {
background-image: image-set(url(foo@1x.png) 1x, url(foo@2x.png) 2x);
}
h1 {
background-image: -webkit-image-set(url('foo@1x.png') 1x, url("foo@2x.png") 2x);
background-image: -webkit-image-set(url("foo@1x.png") 1x, url("foo@2x.png") 2x);
background-image: image-set('foo@1x.png' 1x, "foo@2x.png" 2x);
}
.class {
background-image: -webkit-image-set(url('foo@1x.png') 1x, url("foo@2x.png") 2x);
background-image: -webkit-image-set(url("foo@1x.png") 1x, url("foo@2x.png") 2x);
background-image: image-set('foo@1x.png' 1x, "foo@2x.png" 2x);
}
.class {
-webkit-border-image: -webkit-image-set(url('foo@1x.png') 1x, url("foo@2x.png") 2x);
-webkit-border-image: -webkit-image-set(url("foo@1x.png") 1x, url("foo@2x.png") 2x);
-moz-border-image: image-set('foo@1x.png' 1x, "foo@2x.png" 2x);
-o-border-image: image-set('foo@1x.png' 1x, "foo@2x.png" 2x);
border-image: -webkit-image-set(url('foo@1x.png') 1x, url("foo@2x.png") 2x);
border-image: -webkit-image-set(url("foo@1x.png") 1x, url("foo@2x.png") 2x);
border-image: image-set('foo@1x.png' 1x, "foo@2x.png" 2x);
}
.class {
-webkit-mask: -webkit-image-set(url('foo@1x.png') 1x, url("foo@2x.png") 2x);
mask: -webkit-image-set(url('foo@1x.png') 1x, url("foo@2x.png") 2x);
-webkit-mask: -webkit-image-set(url("foo@1x.png") 1x, url("foo@2x.png") 2x);
mask: -webkit-image-set(url("foo@1x.png") 1x, url("foo@2x.png") 2x);
mask: image-set('foo@1x.png' 1x, "foo@2x.png" 2x);
}
.class {
-webkit-mask-image: -webkit-image-set(url('foo@1x.png') 1x, url("foo@2x.png") 2x);
mask-image: -webkit-image-set(url('foo@1x.png') 1x, url("foo@2x.png") 2x);
-webkit-mask-image: -webkit-image-set(url("foo@1x.png") 1x, url("foo@2x.png") 2x);
mask-image: -webkit-image-set(url("foo@1x.png") 1x, url("foo@2x.png") 2x);
mask-image: image-set('foo@1x.png' 1x, "foo@2x.png" 2x);
}
.class {
list-style: -webkit-image-set(url('foo@1x.png') 1x, url("foo@2x.png") 2x);
list-style: -webkit-image-set(url("foo@1x.png") 1x, url("foo@2x.png") 2x);
list-style: image-set('foo@1x.png' 1x, "foo@2x.png" 2x);
}
.class {
list-style-image: -webkit-image-set(url('foo@1x.png') 1x, url("foo@2x.png") 2x);
list-style-image: -webkit-image-set(url("foo@1x.png") 1x, url("foo@2x.png") 2x);
list-style-image: image-set('foo@1x.png' 1x, "foo@2x.png" 2x);
}
.class {
content: -webkit-image-set(url('foo@1x.png') 1x, url("foo@2x.png") 2x);
content: -webkit-image-set(url("foo@1x.png") 1x, url("foo@2x.png") 2x);
content: image-set('foo@1x.png' 1x, "foo@2x.png" 2x);
}
.broken {
content: -webkit-image-set(url('foo@1x.png') 1x, url("foo@2x.png") 2x) "test";
content: -webkit-image-set(url("foo@1x.png") 1x, url("foo@2x.png") 2x) "test";
content: image-set('foo@1x.png' 1x, "foo@2x.png" 2x) "test";
}

View File

@ -17,7 +17,7 @@ impl VisitMut for IdentReplacer<'_> {
if &*n.value.to_lowercase() == self.from {
n.value = self.to.into();
n.raw = self.to.into();
n.raw = None;
}
}
}
@ -40,7 +40,7 @@ impl VisitMut for FunctionNameReplacer<'_> {
if &*n.name.value.to_lowercase() == self.from {
n.name.value = self.to.into();
n.name.raw = self.to.into();
n.name.raw = None;
}
}
}
@ -63,7 +63,7 @@ impl VisitMut for PseudoClassSelectorNameReplacer<'_> {
if &*n.name.value.to_lowercase() == self.from {
n.name.value = self.to.into();
n.name.raw = self.to.into();
n.name.raw = None;
}
}
}
@ -86,7 +86,7 @@ impl VisitMut for PseudoElementSelectorNameReplacer<'_> {
if &*n.name.value.to_lowercase() == self.from {
n.name.value = self.to.into();
n.name.raw = self.to.into();
n.name.raw = None;
}
}
}
@ -116,7 +116,7 @@ impl VisitMut for PseudoElementOnPseudoClassReplacer<'_> {
name: Ident {
span: name.span,
value: self.to.into(),
raw: self.to.into(),
raw: None,
},
children: None,
})

View File

@ -60,43 +60,43 @@ define!({
pub struct Ident {
pub span: Span,
pub value: JsWord,
pub raw: JsWord,
pub raw: Option<JsWord>,
}
pub struct CustomIdent {
pub span: Span,
pub value: JsWord,
pub raw: JsWord,
pub raw: Option<JsWord>,
}
pub struct CustomPropertyName {
pub span: Span,
pub value: JsWord,
pub raw: JsWord,
pub raw: Option<JsWord>,
}
pub struct DashedIdent {
pub span: Span,
pub value: JsWord,
pub raw: JsWord,
pub raw: Option<JsWord>,
}
pub struct Str {
pub span: Span,
pub value: JsWord,
pub raw: JsWord,
pub raw: Option<JsWord>,
}
pub struct Integer {
pub span: Span,
pub value: i64,
pub raw: JsWord,
pub raw: Option<JsWord>,
}
pub struct Number {
pub span: Span,
pub value: f64,
pub raw: JsWord,
pub raw: Option<JsWord>,
}
pub struct Declaration {
@ -172,7 +172,7 @@ define!({
pub struct HexColor {
pub span: Span,
pub value: JsWord,
pub raw: JsWord,
pub raw: Option<JsWord>,
}
pub enum AlphaValue {
@ -268,10 +268,10 @@ define!({
pub struct UrlValueRaw {
pub span: Span,
pub before: JsWord,
pub after: JsWord,
pub value: JsWord,
pub raw: JsWord,
pub before: Option<JsWord>,
pub raw: Option<JsWord>,
pub after: Option<JsWord>,
}
pub enum UrlModifier {

View File

@ -1624,7 +1624,7 @@ impl Minifier<'_> {
name: swc_css_ast::AtRuleName::Ident(swc_css_ast::Ident {
span: Default::default(),
value: "media".into(),
raw: "media".into(),
raw: None,
}),
prelude: Some(swc_css_ast::AtRulePrelude::MediaPrelude(
media_query_list,
@ -1637,7 +1637,7 @@ impl Minifier<'_> {
value: vec![swc_css_ast::ComponentValue::Str(swc_css_ast::Str {
span: Default::default(),
value: "placeholder".into(),
raw: "placeholder".into(),
raw: None,
})],
}),
})],