Skip to content

Commit ef0b2c7

Browse files
authored
Fix fallbacks support in jss-plugin-vendor-prefixer (#1198)
* fix fallbacks support in jss-plugin-vendor-prefixer * add changelog * test fallbacks with object
1 parent 2912127 commit ef0b2c7

8 files changed

Lines changed: 81 additions & 40 deletions

File tree

changelog.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ Since you are interested in what happens next, in case, you work for a for-profi
77
## Bug fixes
88

99
- [react-jss] Add fallback for `Number.MIN_SAFE_INTEGER`, because not supported by IE <= 11 ([1197](https://github.com/cssinjs/jss/pull/1197))
10+
- [jss-plugin-vendor-prefixer] Fix `fallbacks` syntax support regression ([1198](https://github.com/cssinjs/jss/pull/1198))
1011

1112
## 10.0.0-alpha.26 (2019-9-22)
1213

packages/css-jss/.size-snapshot.json

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
{
22
"dist/css-jss.js": {
3-
"bundled": 57635,
4-
"minified": 20287,
5-
"gzipped": 6833
3+
"bundled": 57848,
4+
"minified": 20363,
5+
"gzipped": 6871
66
},
77
"dist/css-jss.min.js": {
8-
"bundled": 56873,
9-
"minified": 19825,
10-
"gzipped": 6619
8+
"bundled": 57086,
9+
"minified": 19901,
10+
"gzipped": 6656
1111
},
1212
"dist/css-jss.cjs.js": {
1313
"bundled": 2919,

packages/jss-plugin-vendor-prefixer/.size-snapshot.json

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,23 @@
11
{
22
"dist/jss-plugin-vendor-prefixer.js": {
3-
"bundled": 17778,
4-
"minified": 5702,
5-
"gzipped": 2224
3+
"bundled": 17991,
4+
"minified": 5778,
5+
"gzipped": 2255
66
},
77
"dist/jss-plugin-vendor-prefixer.min.js": {
8-
"bundled": 17778,
9-
"minified": 5702,
10-
"gzipped": 2224
8+
"bundled": 17991,
9+
"minified": 5778,
10+
"gzipped": 2255
1111
},
1212
"dist/jss-plugin-vendor-prefixer.cjs.js": {
13-
"bundled": 1375,
14-
"minified": 627,
15-
"gzipped": 360
13+
"bundled": 1574,
14+
"minified": 703,
15+
"gzipped": 406
1616
},
1717
"dist/jss-plugin-vendor-prefixer.esm.js": {
18-
"bundled": 1325,
19-
"minified": 574,
20-
"gzipped": 319,
18+
"bundled": 1524,
19+
"minified": 650,
20+
"gzipped": 366,
2121
"treeshaked": {
2222
"rollup": {
2323
"code": 31,

packages/jss-plugin-vendor-prefixer/src/index.js

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,13 @@ export default function jssVendorPrefixer(): Plugin {
1515
}
1616
}
1717

18-
function onProcessStyle(style, rule) {
19-
if (rule.type !== 'style') return style
20-
18+
function prefixStyle(style) {
2119
for (const prop in style) {
2220
const value = style[prop]
23-
21+
if (prop === 'fallbacks' && Array.isArray(value)) {
22+
style[prop] = value.map(prefixStyle)
23+
continue
24+
}
2425
let changeProp = false
2526
const supportedProp = vendor.supportedProperty(prop)
2627
if (supportedProp && supportedProp !== prop) changeProp = true
@@ -38,6 +39,12 @@ export default function jssVendorPrefixer(): Plugin {
3839
return style
3940
}
4041

42+
function onProcessStyle(style, rule) {
43+
if (rule.type !== 'style') return style
44+
45+
return prefixStyle(style)
46+
}
47+
4148
function onChangeValue(value, prop) {
4249
return vendor.supportedValue(prop, toCssValue(value)) || value
4350
}

packages/jss-plugin-vendor-prefixer/src/index.test.js

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import expect from 'expect.js'
22
import {create} from 'jss'
33
import * as cssVendor from 'css-vendor'
44
import browser from 'detect-browser'
5+
import {stripIndent} from 'common-tags'
56
import functionPlugin from 'jss-plugin-rule-value-function'
67

78
import vendorPrefixer from './index'
@@ -162,4 +163,36 @@ describe('jss-plugin-vendor-prefixer', () => {
162163
expect(sheet.toString()).to.be(`.a-id {\n display: ${supportedValue};\n}`)
163164
})
164165
})
166+
167+
describe('prefix fallbacks', () => {
168+
it('should prefix array of objects', () => {
169+
const sheet = jss.createStyleSheet({
170+
a: {
171+
display: 'run-in',
172+
fallbacks: [{display: 'inline'}]
173+
}
174+
})
175+
expect(sheet.toString()).to.be(stripIndent`
176+
.a-id {
177+
display: inline;
178+
display: run-in;
179+
}
180+
`)
181+
})
182+
183+
it('should prefix an object', () => {
184+
const sheet = jss.createStyleSheet({
185+
a: {
186+
display: 'run-in',
187+
fallbacks: {display: 'inline'}
188+
}
189+
})
190+
expect(sheet.toString()).to.be(stripIndent`
191+
.a-id {
192+
display: inline;
193+
display: run-in;
194+
}
195+
`)
196+
})
197+
})
165198
})

packages/jss-preset-default/.size-snapshot.json

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
{
22
"dist/jss-preset-default.js": {
3-
"bundled": 54879,
4-
"minified": 19521,
5-
"gzipped": 6486
3+
"bundled": 55092,
4+
"minified": 19597,
5+
"gzipped": 6524
66
},
77
"dist/jss-preset-default.min.js": {
8-
"bundled": 54117,
9-
"minified": 19059,
10-
"gzipped": 6271
8+
"bundled": 54330,
9+
"minified": 19135,
10+
"gzipped": 6310
1111
},
1212
"dist/jss-preset-default.cjs.js": {
1313
"bundled": 1329,

packages/jss-starter-kit/.size-snapshot.json

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
{
22
"dist/jss-starter-kit.js": {
3-
"bundled": 70421,
4-
"minified": 29561,
5-
"gzipped": 9109
3+
"bundled": 70634,
4+
"minified": 29637,
5+
"gzipped": 9145
66
},
77
"dist/jss-starter-kit.min.js": {
8-
"bundled": 69659,
9-
"minified": 29099,
10-
"gzipped": 8896
8+
"bundled": 69872,
9+
"minified": 29175,
10+
"gzipped": 8929
1111
},
1212
"dist/jss-starter-kit.cjs.js": {
1313
"bundled": 2592,

packages/react-jss/.size-snapshot.json

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
{
22
"dist/react-jss.js": {
3-
"bundled": 169164,
4-
"minified": 58306,
5-
"gzipped": 19067
3+
"bundled": 169377,
4+
"minified": 58382,
5+
"gzipped": 19100
66
},
77
"dist/react-jss.min.js": {
8-
"bundled": 112488,
9-
"minified": 41697,
10-
"gzipped": 14145
8+
"bundled": 112701,
9+
"minified": 41773,
10+
"gzipped": 14177
1111
},
1212
"dist/react-jss.cjs.js": {
1313
"bundled": 27027,

0 commit comments

Comments
 (0)