Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

When rendering declarations of KeyFrames disable minification #665

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 4 additions & 0 deletions src/properties/transform.rs
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,10 @@ impl ToCss for TransformList {
return Ok(());
}

// TODO: Decouple minification of representation from minifaction of white space.
// We don't have access to context here, so we can't tell when to minify this
// vs when we shouldn't ( inside a KeyFrame decl ).
// Minification in to_css should be restricted to white space,
if dest.minify {
// Combine transforms into a single matrix.
if let Some(matrix) = self.to_matrix() {
Expand Down
17 changes: 15 additions & 2 deletions src/rules/keyframes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -355,7 +355,11 @@ impl<'i> ToCss for Keyframe<'i> {
selector.to_css(dest)?;
}

self.declarations.to_css_block(dest)
// We can't safely minify declarations of keyframes without doing more analysis
dest.minify = false;
let result = self.declarations.to_css_block(dest);
dest.minify = true;
result
}
}

Expand Down Expand Up @@ -387,9 +391,18 @@ impl<'a, 'i> QualifiedRuleParser<'i> for KeyframeListParser {
) -> Result<Self::QualifiedRule, ParseError<'i, ParserError<'i>>> {
// For now there are no options that apply within @keyframes
let options = ParserOptions::default();

let mut declaration_block = DeclarationBlock::parse(input, &options)?;

// Per https://developer.mozilla.org/en-US/docs/Web/CSS/@keyframes#!important_in_a_keyframe
// !important is ignored in a declaration block, so we strip it here.
declaration_block
.declarations
.append(&mut declaration_block.important_declarations);

Ok(Keyframe {
selectors,
declarations: DeclarationBlock::parse(input, &options)?,
declarations: declaration_block,
})
}
}
Expand Down