@@ -267,30 +267,32 @@ impl<'a, 'b, 'c, W: std::fmt::Write + Sized> Printer<'a, 'b, 'c, W> {
267267 /// Writes a CSS identifier to the underlying destination, escaping it
268268 /// as appropriate. If the `css_modules` option was enabled, then a hash
269269 /// is added, and the mapping is added to the CSS module.
270- pub fn write_ident ( & mut self , ident : & str ) -> Result < ( ) , PrinterError > {
271- if let Some ( css_module) = & mut self . css_module {
272- let dest = & mut self . dest ;
273- let mut first = true ;
274- css_module. config . pattern . write (
275- & css_module. hashes [ self . loc . source_index as usize ] ,
276- & css_module. sources [ self . loc . source_index as usize ] ,
277- ident,
278- |s| {
279- self . col += s. len ( ) as u32 ;
280- if first {
281- first = false ;
282- serialize_identifier ( s, dest)
283- } else {
284- serialize_name ( s, dest)
285- }
286- } ,
287- ) ?;
270+ pub fn write_ident ( & mut self , ident : & str , handle_css_module : bool ) -> Result < ( ) , PrinterError > {
271+ if handle_css_module {
272+ if let Some ( css_module) = & mut self . css_module {
273+ let dest = & mut self . dest ;
274+ let mut first = true ;
275+ css_module. config . pattern . write (
276+ & css_module. hashes [ self . loc . source_index as usize ] ,
277+ & css_module. sources [ self . loc . source_index as usize ] ,
278+ ident,
279+ |s| {
280+ self . col += s. len ( ) as u32 ;
281+ if first {
282+ first = false ;
283+ serialize_identifier ( s, dest)
284+ } else {
285+ serialize_name ( s, dest)
286+ }
287+ } ,
288+ ) ?;
288289
289- css_module. add_local ( & ident, & ident, self . loc . source_index ) ;
290- } else {
291- serialize_identifier ( ident , self ) ? ;
290+ css_module. add_local ( & ident, & ident, self . loc . source_index ) ;
291+ return Ok ( ( ) ) ;
292+ }
292293 }
293294
295+ serialize_identifier ( ident, self ) ?;
294296 Ok ( ( ) )
295297 }
296298
0 commit comments