Skip to content

Commit

Permalink
2.0.0
Browse files Browse the repository at this point in the history
  • Loading branch information
bloodyowl committed Nov 20, 2015
1 parent 2597241 commit 073ec87
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 5 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "stile",
"version": "1.0.0",
"version": "2.0.0",
"description": "stylesheet creator for js inline-styles",
"main": "./lib/index.js",
"scripts": {
Expand Down
2 changes: 1 addition & 1 deletion src/__tests__/autoprefix-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ tape("autoprefix", (test) => {
display: "flex",
}),
{
display: "flex;display:-webkit-flex;display:-ms-flexbox",
display: "flex",
}
)
test.deepEqual(
Expand Down
17 changes: 14 additions & 3 deletions src/autoprefix.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,15 @@
import getSupportedCSSValue from "./getSupportedCSSValue"

const FLEX_VALUE = getSupportedCSSValue(
"display",
["flex", "-webkit-flex", "-ms-flexbox"]
)

const INLINE_FLEX_VALUE = getSupportedCSSValue(
"display",
["inline-flex", "-webkit-inline-flex", "-ms-inline-flexbox"]
)

// from https://github.com/petehunt/jsxstyle/blob/master/lib/autoprefix.js
export default function autoprefix(style) {

Expand Down Expand Up @@ -98,12 +110,11 @@ export default function autoprefix(style) {
}

if (style.display === "flex") {
style.display = style.display + ";display:-webkit-flex;display:-ms-flexbox"
style.display = FLEX_VALUE
}

if (style.display === "inline-flex") {
style.display =
style.display + ";display:-webkit-inline-flex;display:-ms-inline-flexbox"
style.display = INLINE_FLEX_VALUE
}

return style
Expand Down
9 changes: 9 additions & 0 deletions src/getSupportedCSSValue.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
const dummy = document.createElement("div")

const getSupportedCSSValue = (property, values) => values.find((item) => {
dummy.style[property] = ""
dummy.style[property] = item
return dummy.style[property] !== ""
})

export default getSupportedCSSValue

0 comments on commit 073ec87

Please sign in to comment.