From 3b28551183c0fdafd9249adbb8152d3ed2024655 Mon Sep 17 00:00:00 2001 From: LvChengbin Date: Mon, 24 Aug 2020 00:16:37 +0800 Subject: [PATCH] fixed #214 --- src/supported-value.js | 2 +- src/supported-value.test.js | 11 +++++++++++ 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/src/supported-value.js b/src/supported-value.js index 53316dcb..4dc2b858 100644 --- a/src/supported-value.js +++ b/src/supported-value.js @@ -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 diff --git a/src/supported-value.test.js b/src/supported-value.test.js index a047a5b2..7b7f130b 100644 --- a/src/supported-value.test.js +++ b/src/supported-value.test.js @@ -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') + }) }) })