-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.js
More file actions
30 lines (25 loc) · 727 Bytes
/
index.js
File metadata and controls
30 lines (25 loc) · 727 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
/**
* Add !important to every css rule - mostly for code that ends up in uncontrolled environments (aka, widgets)
*
* See https://github.com/cssinjs/jss/issues/209
*
* @api public
*/
export default function jssAllImportant() {
function onProcessStyle(style, rule) {
// !important isn't valid on keyframes
if(rule.options.parent.type === 'keyframes') return style;
if (rule.type !== 'style') return style;
for (const prop in style) {
style[prop] = style[prop] + ' !important';
}
return style;
}
function onChangeValue(value, prop) {
return value + ' !important';
}
return {
onProcessStyle,
onChangeValue
};
}