Skip to content

Commit 4c588d2

Browse files
committed
Set styles as strings if one of the values contains !important definitions.
Fixes #728
1 parent f909a14 commit 4c588d2

File tree

3 files changed

+22
-4
lines changed

3 files changed

+22
-4
lines changed

runtime/src/styles.js

+20-2
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,18 @@
55
// style=[{"color", "red"}] - A Mint Array of tuples
66
// style={`{color: "red"}`} - A JavaScript object
77
export const style = (items) => {
8+
let important = false;
89
const result = {};
910

1011
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;
1220
};
1321

1422
for (let item of items) {
@@ -31,5 +39,15 @@ export const style = (items) => {
3139
}
3240
}
3341

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+
}
3553
};

0 commit comments

Comments
 (0)