1- using static CssInCSharp . Compiler . Serializer ;
1+ using System ;
2+ using static CssInCSharp . Compiler . Serializer ;
23using static CssInCSharp . Compiler . Parser ;
34using static CssInCSharp . Constant ;
45using System . Collections . Generic ;
@@ -10,10 +11,10 @@ namespace CssInCSharp
1011{
1112 public sealed partial class CSSObject
1213 {
13- private readonly Dictionary < string , CSSObject > _styles = new ( ) ;
14+ private readonly Dictionary < string , CSSInterpolation > _styles = new ( ) ;
1415 private readonly Dictionary < string , IProperty > _properties = new ( ) ;
1516 public Dictionary < string , IProperty > GetProperties ( ) => _properties ;
16- public Dictionary < string , CSSObject > GetStyles ( ) => _styles ;
17+ public Dictionary < string , CSSInterpolation > GetStyles ( ) => _styles ;
1718
1819 public CSSInterpolation this [ string key ]
1920 {
@@ -74,15 +75,21 @@ internal string ParseStyle(bool root, bool injectHash, string hashId, List<(stri
7475 mergedKey = "" ;
7576 nextRoot = true ;
7677 }
77-
78- sb . Append ( $ "{ mergedKey } {{{subStyle.Value.ParseStyle(nextRoot, subInjectHash, hashId, effects)}}}") ;
78+ var values = subStyle . Value . ToCssArray ( ) ;
79+ var valueStr = new StringBuilder ( ) ;
80+ foreach ( var value in values )
81+ {
82+ valueStr . Append ( value . ParseStyle ( nextRoot , subInjectHash , hashId , effects ) ) ;
83+ }
84+ sb . Append ( $ "{ mergedKey } {{{valueStr}}}") ;
7985 }
8086
8187 return sb . ToString ( ) ;
8288 }
8389
8490 public CSSObject Merge ( CSSObject css )
8591 {
92+ if ( css == null ) return this ;
8693 var props = css . GetProperties ( ) ;
8794 foreach ( var prop in props )
8895 {
@@ -96,7 +103,7 @@ public CSSObject Merge(CSSObject css)
96103 if ( _styles . TryGetValue ( style . Key , out var value ) )
97104 {
98105 // if exists, merge to sub style sheet.
99- value . Merge ( style . Value ) ;
106+ value . AsT0 . Merge ( style . Value . AsT0 ) ;
100107 }
101108 else
102109 {
@@ -108,15 +115,6 @@ public CSSObject Merge(CSSObject css)
108115 return this ;
109116 }
110117
111- public CSSObject Merge ( CSSObject [ ] objects )
112- {
113- foreach ( var css in objects )
114- {
115- Merge ( css ) ;
116- }
117- return this ;
118- }
119-
120118 private void SetStyle ( string key , CSSInterpolation value )
121119 {
122120 if ( key == null ) return ;
@@ -138,14 +136,13 @@ private void SetStyle(string key, CSSInterpolation value)
138136 /*
139137 * if is CSSObject or CSSObject[]
140138 */
141- var cssObject = value . IsT0 ? value . AsT0 : new CSSObject ( ) . Merge ( value . ToCssArray ( ) ) ;
142- if ( cssObject == null ) return ;
143139 if ( key == MERGE_OPERATOR )
144140 {
145- Merge ( cssObject ) ;
141+ if ( ! value . IsT0 ) throw new Exception ( "Invalid merge value type." ) ;
142+ Merge ( value . AsT0 ) ;
146143 return ;
147144 }
148- _styles [ key ] = cssObject ;
145+ _styles [ key ] = value ;
149146 }
150147
151148 private string InjectSelectorHash ( string key , string hashId )
0 commit comments