Repository navigation
css: parse composes as CSS modules syntax only in a CSS module
#45961
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
Changes from all commits
543b3e4
c9cfac8
757eba4
2ab9346
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -201,37 +201,34 @@ impl<R> StyleRule<R> { | |
| // The CSS modules `composes` property is handled specially, and omitted during printing. | ||
| // We need to add the classes it references to the list for the selectors in this rule. | ||
| if let Property::Composes(composes) = decl { | ||
| if dest.is_nested() && dest.css_module.is_some() { | ||
| // `Property::parse` makes this property only in a CSS module. | ||
| debug_assert!(dest.css_module.is_some()); | ||
| if dest.is_nested() { | ||
| return dest.new_error( | ||
| PrinterErrorKind::invalid_composes_nesting, | ||
| Some(composes.cssparser_loc), | ||
| ); | ||
| } | ||
|
|
||
| if dest.css_module.is_some() { | ||
| // `handle_composes` needs `&mut dest` while the | ||
| // module also lives in `dest.css_module`. Move the | ||
| // module out for the duration of the call, then put | ||
| // it back before any `dest.new_error` early return. | ||
| let mut cm = dest.css_module.take(); | ||
| let err = if let Some(css_module) = &mut cm { | ||
| css_module | ||
| .handle_composes( | ||
| dest, | ||
| &self.selectors, | ||
| composes, | ||
| self.loc.source_index, | ||
| ) | ||
| .err() | ||
| } else { | ||
| None | ||
| }; | ||
| dest.css_module = cm; | ||
| if let Some(error_kind) = err { | ||
| return dest.new_error(error_kind, Some(composes.cssparser_loc)); | ||
| } | ||
| continue; | ||
| // Move the module out of `dest`: `handle_composes` also takes `&mut dest`. | ||
| let mut cm = dest.css_module.take(); | ||
| let err = if let Some(css_module) = &mut cm { | ||
| css_module | ||
| .handle_composes( | ||
| dest, | ||
| &self.selectors, | ||
| composes, | ||
| self.loc.source_index, | ||
| ) | ||
| .err() | ||
| } else { | ||
| None | ||
| }; | ||
| dest.css_module = cm; | ||
| if let Some(error_kind) = err { | ||
| return dest.new_error(error_kind, Some(composes.cssparser_loc)); | ||
| } | ||
| continue; | ||
|
Comment on lines
203
to
+231
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🟣 pre-existing, not blocking: pre-existing nit: a minified CSS module whose rule has a Why this was flaggedA CSS module such as Verification: pre-existing (nit-sized): triggered whenever a CSS module rule contains a
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Confirmed, and it is the same without this change. This PR does not change it. It leaves the output of a CSS module byte-identical, and this fix changes minified CSS module output. It needs its own change, with a test for a minified module rule that has |
||
| } | ||
|
|
||
| dest.newline()?; | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.