Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Handle case where css float property is converted to cssFloat by autoprefixer camelCase function #224

Merged
merged 3 commits into from
Aug 2, 2017
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 8 additions & 5 deletions src/ast-object.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,9 +57,8 @@ function prefixAst (args, t) {
return properties.push(
t.objectProperty(key, prefixedValue, property.computed)
)

// literal value or array of literal values
} else if (
// literal value or array of literal values
isLiteral(property.value) ||
(t.isArrayExpression(property.value) &&
property.value.elements.every(isLiteral))
Expand All @@ -79,9 +78,13 @@ function prefixAst (args, t) {
const prefixedStyle = expandCSSFallbacks(prefixer(style))

for (let k in prefixedStyle) {
const key = t.isStringLiteral(property.key)
? t.stringLiteral(k)
: t.identifier(k)
// https://github.com/stevenvachon/camelcase-css/blob/master/index.js#L16
const prefixedKey = k === 'cssFloat' ? 'float' : k

let key = t.isStringLiteral(property.key)
? t.stringLiteral(prefixedKey)
: t.identifier(prefixedKey)

const val = prefixedStyle[k]
let value

Expand Down
1 change: 1 addition & 0 deletions test/__snapshots__/css.test.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,7 @@ exports[`css handles more than 10 dynamic properties 1`] = `

exports[`css handles objects 1`] = `
.glamor-0 {
float: left;
display: -webkit-box;
display: -ms-flexbox;
display: flex;
Expand Down
1 change: 1 addition & 0 deletions test/babel/__snapshots__/css.test.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -323,6 +323,7 @@ exports[`babel css inline nested expanded properties 1`] = `
exports[`babel css inline object with a bunch of stuff 1`] = `
"
const cls2 = css({
'float': 'left',
'display': '-webkit-box; display: -ms-flexbox; display: flex',
'WebkitBoxFlex': '1',
'msFlex': '1',
Expand Down
1 change: 1 addition & 0 deletions test/babel/css.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -234,6 +234,7 @@ describe('babel css', () => {
test('object with a bunch of stuff', () => {
const basic = `
const cls2 = css({
float: 'left',
display: 'flex',
flex: 1,
alignItems: \`\${'center'}\`
Expand Down
1 change: 1 addition & 0 deletions test/css.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ describe('css', () => {

test('handles objects', () => {
const cls1 = css({
float: 'left',
display: 'flex',
color: `${'blue'}`,
fontSize: `${'20px'}`,
Expand Down