Skip to content

Commit

Permalink
catch IE exceptions when feature testing a value
Browse files Browse the repository at this point in the history
  • Loading branch information
kof committed Jun 14, 2016
1 parent 8d51b9e commit 861bda2
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 3 deletions.
4 changes: 4 additions & 0 deletions history.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## 0.3.5 / 2016-06-15

- catch IE exceptions when feature testing a value

## 0.3.3 / 2015-04-13

- do nothing server-side
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "css-vendor",
"description": "CSS vendor prefix detection and property feature testing.",
"version": "0.3.3",
"version": "0.3.4",
"author": {
"name": "Oleg Slobodskoi",
"email": "oleg008@gmail.com"
Expand Down
11 changes: 9 additions & 2 deletions src/supported-value.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,15 @@ export default function supportedValue(property, value) {

if (cache[cacheKey] != null) return cache[cacheKey]

// Test value as it is.
el.style[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] = value
}
catch (err) {
cache[cacheKey] = false
return false
}

// Value is supported as it is.
if (el.style[property] === value) {
Expand Down
4 changes: 4 additions & 0 deletions test/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,3 +47,7 @@ test('known value prefixed', function () {
test('unknown value', function () {
equal(cssVendor.supportedValue('display', 'xxx'), false)
})

test('bad "content" value', function () {
equal(cssVendor.supportedValue('content', 'bar'), false)
})

0 comments on commit 861bda2

Please sign in to comment.