File tree Expand file tree Collapse file tree 5 files changed +25
-7
lines changed
src/compiler/phases/3-transform/server
tests/server-side-rendering/samples/head-raw-elements-content Expand file tree Collapse file tree 5 files changed +25
-7
lines changed Original file line number Diff line number Diff line change
1
+ ---
2
+ " svelte " : patch
3
+ ---
4
+
5
+ fix missing classes after dynamic expressions in class attribute
Original file line number Diff line number Diff line change @@ -853,9 +853,7 @@ function serialize_attribute_value(
853
853
/** @type {import('estree').Expression[] } */
854
854
const expressions = [ ] ;
855
855
856
- if ( attribute_value [ 0 ] . type !== 'Text' ) {
857
- quasis . push ( b . quasi ( '' , false ) ) ;
858
- }
856
+ quasis . push ( b . quasi ( '' , false ) ) ;
859
857
860
858
let i = 0 ;
861
859
for ( const node of attribute_value ) {
@@ -866,17 +864,16 @@ function serialize_attribute_value(
866
864
// don't trim, space could be important to separate from expression tag
867
865
data = data . replace ( regex_whitespaces_strict , ' ' ) ;
868
866
}
869
- quasis . push ( b . quasi ( data , i === attribute_value . length ) ) ;
867
+ const last = /** @type {import('estree').TemplateElement } */ ( quasis . at ( - 1 ) ) ;
868
+ last . value . raw += data ;
870
869
} else {
871
870
expressions . push (
872
871
b . call (
873
872
'$.stringify' ,
874
873
/** @type {import('estree').Expression } */ ( context . visit ( node . expression ) )
875
874
)
876
875
) ;
877
- if ( i === attribute_value . length || attribute_value [ i ] ?. type !== 'Text' ) {
878
- quasis . push ( b . quasi ( '' , true ) ) ;
879
- }
876
+ quasis . push ( b . quasi ( '' , i + 1 === attribute_value . length ) ) ;
880
877
}
881
878
}
882
879
Original file line number Diff line number Diff line change
1
+ import { test } from '../../test' ;
2
+
3
+ export default test ( { } ) ;
Original file line number Diff line number Diff line change
1
+ < div class ="bar baz svelte-m782ot "> bar</ div >
2
+ < div class ="foo bar baz svelte-m782ot "> bar</ div >
Original file line number Diff line number Diff line change
1
+ <script >
2
+ const dynamic_value = ' bar' ;
3
+ </script >
4
+ <div class =" {dynamic_value } baz" >bar</div >
5
+ <div class ="foo {dynamic_value } baz" >bar</div >
6
+
7
+ <style >
8
+ .baz {
9
+ color : red ;
10
+ }
11
+ </style >
You can’t perform that action at this time.
0 commit comments