Skip to content

Commit 3b28551

Browse files
committed
fixed cssinjs#214
1 parent 54a9f4b commit 3b28551

File tree

2 files changed

+12
-1
lines changed

2 files changed

+12
-1
lines changed

src/supported-value.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ export default function supportedValue(property, value) {
6464
// IE can even throw an error in some cases, for e.g. style.content = 'bar'.
6565
try {
6666
// Test value as it is.
67-
el.style[property] = prefixedValue
67+
el.style.setProperty(property, ...prefixedValue.split(/!(?=important$)/))
6868
} catch (err) {
6969
// Return false if value not supported.
7070
cache[cacheKey] = false

src/supported-value.test.js

+11
Original file line numberDiff line numberDiff line change
@@ -78,5 +78,16 @@ describe('css-vendor', () => {
7878
prefix.js === 'ms' && prefix.browser !== 'edge' ? false : value
7979
)
8080
})
81+
82+
it('should support !important property', () => {
83+
expect(supportedValue('border', 'solid 1px indigo !important')).to.be(
84+
'solid 1px indigo !important'
85+
)
86+
expect(supportedValue('font-size', '12px!important')).to.be('12px!important')
87+
})
88+
89+
it('should support content property with the value contains !important string', () => {
90+
expect(supportedValue('content', '!important')).to.be('!important')
91+
})
8192
})
8293
})

0 commit comments

Comments
 (0)