@@ -399,6 +399,11 @@ fn write_declaration<Wr: Write>(
399399) -> Result < ( ) , InlineError > {
400400 writer. write_all ( name. as_bytes ( ) ) ?;
401401 writer. write_all ( STYLE_SEPARATOR ) ?;
402+ write_declaration_value ( writer, value)
403+ }
404+
405+ #[ inline]
406+ fn write_declaration_value < Wr : Write > ( writer : & mut Wr , value : & str ) -> Result < ( ) , InlineError > {
402407 let value = value. trim ( ) ;
403408 if value. as_bytes ( ) . contains ( & b'"' ) {
404409 // Roughly based on `str::replace`
@@ -429,9 +434,7 @@ macro_rules! push_or_update {
429434 ( $style_buffer: expr, $length: expr, $name: expr, $value: expr) => { {
430435 if let Some ( style) = $style_buffer. get_mut( $length) {
431436 style. clear( ) ;
432- style. extend_from_slice( $name. as_bytes( ) ) ;
433- style. extend_from_slice( STYLE_SEPARATOR ) ;
434- style. extend_from_slice( $value. trim( ) . as_bytes( ) ) ;
437+ write_declaration( style, & $name, $value) ?;
435438 } else {
436439 let value = $value. trim( ) ;
437440 let mut style = Vec :: with_capacity(
@@ -440,9 +443,7 @@ macro_rules! push_or_update {
440443 . saturating_add( STYLE_SEPARATOR . len( ) )
441444 . saturating_add( value. len( ) ) ,
442445 ) ;
443- style. extend_from_slice( $name. as_bytes( ) ) ;
444- style. extend_from_slice( STYLE_SEPARATOR ) ;
445- style. extend_from_slice( value. as_bytes( ) ) ;
446+ write_declaration( & mut style, & $name, $value) ?;
446447 $style_buffer. push( style) ;
447448 } ;
448449 $length = $length. saturating_add( 1 ) ;
@@ -507,7 +508,7 @@ fn merge_styles<Wr: Write>(
507508 ( Some ( value) , Some ( buffer) ) => {
508509 // We keep the rule name and the colon-space suffix - '<rule>: `
509510 buffer. truncate ( property. len ( ) . saturating_add ( STYLE_SEPARATOR . len ( ) ) ) ;
510- buffer . extend_from_slice ( value. trim ( ) . as_bytes ( ) ) ;
511+ write_declaration_value ( buffer , value) ? ;
511512 }
512513 // There's no existing rule with the same name, but the new rule is `!important`
513514 // In this case, we add the new rule with the `!important` suffix removed
0 commit comments