File tree 3 files changed +22
-4
lines changed
3 files changed +22
-4
lines changed Original file line number Diff line number Diff line change 5
5
// style=[{"color", "red"}] - A Mint Array of tuples
6
6
// style={`{color: "red"}`} - A JavaScript object
7
7
export const style = ( items ) => {
8
+ let important = false ;
8
9
const result = { } ;
9
10
10
11
const setKeyValue = ( key , value ) => {
11
- result [ key . toString ( ) . trim ( ) ] = value . toString ( ) . trim ( ) ;
12
+ const stringValue =
13
+ value . toString ( ) . trim ( ) ;
14
+
15
+ if ( stringValue . indexOf ( "!important" ) ) {
16
+ important = true ;
17
+ }
18
+
19
+ result [ key . toString ( ) . trim ( ) ] = stringValue ;
12
20
} ;
13
21
14
22
for ( let item of items ) {
@@ -31,5 +39,15 @@ export const style = (items) => {
31
39
}
32
40
}
33
41
34
- return result ;
42
+ if ( important ) {
43
+ let string = "" ;
44
+
45
+ for ( let key in result ) {
46
+ string += `${ key } :${ result [ key ] } ;`
47
+ }
48
+
49
+ return string ;
50
+ } else {
51
+ return result ;
52
+ }
35
53
} ;
You can’t perform that action at this time.
0 commit comments