Skip to content

Commit

Permalink
fixed cssinjs#214
Browse files Browse the repository at this point in the history
  • Loading branch information
LvChengbin committed Aug 23, 2020
1 parent 54a9f4b commit 3b28551
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/supported-value.js
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ export default function supportedValue(property, value) {
// IE can even throw an error in some cases, for e.g. style.content = 'bar'.
try {
// Test value as it is.
el.style[property] = prefixedValue
el.style.setProperty(property, ...prefixedValue.split(/!(?=important$)/))
} catch (err) {
// Return false if value not supported.
cache[cacheKey] = false
Expand Down
11 changes: 11 additions & 0 deletions src/supported-value.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -78,5 +78,16 @@ describe('css-vendor', () => {
prefix.js === 'ms' && prefix.browser !== 'edge' ? false : value
)
})

it('should support !important property', () => {
expect(supportedValue('border', 'solid 1px indigo !important')).to.be(
'solid 1px indigo !important'
)
expect(supportedValue('font-size', '12px!important')).to.be('12px!important')
})

it('should support content property with the value contains !important string', () => {
expect(supportedValue('content', '!important')).to.be('!important')
})
})
})

0 comments on commit 3b28551

Please sign in to comment.