@@ -25,64 +25,6 @@ export function transform_component(analysis, source, options) {
25
25
} ;
26
26
}
27
27
28
- const css =
29
- analysis . css . ast && ! analysis . inject_styles
30
- ? render_stylesheet ( source , analysis , options )
31
- : null ;
32
-
33
- outer: for ( const element of analysis . elements ) {
34
- if ( element . metadata . scoped ) {
35
- // Dynamic elements in dom mode always use spread for attributes and therefore shouldn't have a class attribute added to them
36
- // TODO this happens during the analysis phase, which shouldn't know anything about client vs server
37
- if ( element . type === 'SvelteElement' && options . generate === 'client' ) continue ;
38
-
39
- /** @type {import('#compiler').Attribute | undefined } */
40
- let class_attribute = undefined ;
41
-
42
- for ( const attribute of element . attributes ) {
43
- if ( attribute . type === 'SpreadAttribute' ) {
44
- // The spread method appends the hash to the end of the class attribute on its own
45
- continue outer;
46
- }
47
-
48
- if ( attribute . type !== 'Attribute' ) continue ;
49
- if ( attribute . name . toLowerCase ( ) !== 'class' ) continue ;
50
-
51
- class_attribute = attribute ;
52
- }
53
-
54
- if ( class_attribute && class_attribute . value !== true ) {
55
- const chunks = class_attribute . value ;
56
-
57
- if ( chunks . length === 1 && chunks [ 0 ] . type === 'Text' ) {
58
- chunks [ 0 ] . data += ` ${ analysis . css . hash } ` ;
59
- } else {
60
- chunks . push ( {
61
- type : 'Text' ,
62
- data : ` ${ analysis . css . hash } ` ,
63
- raw : ` ${ analysis . css . hash } ` ,
64
- start : - 1 ,
65
- end : - 1 ,
66
- parent : null
67
- } ) ;
68
- }
69
- } else {
70
- element . attributes . push (
71
- create_attribute ( 'class' , - 1 , - 1 , [
72
- {
73
- type : 'Text' ,
74
- data : analysis . css . hash ,
75
- raw : analysis . css . hash ,
76
- parent : null ,
77
- start : - 1 ,
78
- end : - 1
79
- }
80
- ] )
81
- ) ;
82
- }
83
- }
84
- }
85
-
86
28
const program =
87
29
options . generate === 'server'
88
30
? server_component ( analysis , options )
@@ -110,6 +52,11 @@ export function transform_component(analysis, source, options) {
110
52
} ) ;
111
53
merge_with_preprocessor_map ( js , options , js_source_name ) ;
112
54
55
+ const css =
56
+ analysis . css . ast && ! analysis . inject_styles
57
+ ? render_stylesheet ( source , analysis , options )
58
+ : null ;
59
+
113
60
return {
114
61
js,
115
62
css,
0 commit comments