Skip to content

Commit c191781

Browse files
author
Robin Frischmann
authored
Merge pull request #82 from alexyaseen/master
splits cursor plugin into two separate plugins for zoom and grab, always adds prefix to grab and grabbing
2 parents 5e2bf20 + 8fdb83a commit c191781

File tree

8 files changed

+328
-126
lines changed

8 files changed

+328
-126
lines changed

dist/prefixer.js

Lines changed: 279 additions & 113 deletions
Large diffs are not rendered by default.

dist/prefixer.min.js

Lines changed: 2 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

docs/Plugins.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,10 @@ Sometimes it is not enough to just prefix a property, but you also need to prefi
33

44
### calc
55
Adds support for prefixed `calc` values on any property.
6-
### cursor
7-
Adds support for prefixed new `cursor` values `zoom-in`, `zoom-out`, `grab`, `grabbing`.
6+
### zoomCursor
7+
Adds support for prefixed new `cursor` values `zoom-in` and `zoom-out`.
8+
### grabCursor
9+
Adds support for prefixed new `cursor` values `grab` and `grabbing`.
810

911
### flex
1012
Adds support for prefixed `display` values using `display: flex` or `display: inline-flex`.

modules/Prefixer.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,8 @@ import assign from './utils/assign'
66
import prefixProps from './prefixProps'
77

88
import calc from './plugins/calc'
9-
import cursor from './plugins/cursor'
9+
import zoomCursor from './plugins/zoomCursor'
10+
import grabCursor from './plugins/grabCursor'
1011
import flex from './plugins/flex'
1112
import sizing from './plugins/sizing'
1213
import gradient from './plugins/gradient'
@@ -17,7 +18,8 @@ import flexboxOld from './plugins/flexboxOld'
1718

1819
const plugins = [
1920
calc,
20-
cursor,
21+
zoomCursor,
22+
grabCursor,
2123
sizing,
2224
gradient,
2325
transition,

modules/plugins/grabCursor.js

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
import camelToDashCase from '../utils/camelToDashCase'
2+
3+
const values = {
4+
'grab': true,
5+
'grabbing': true
6+
}
7+
8+
export default function cursor({ property, value, browserInfo: { browser, version }, prefix: { css }, keepUnprefixed }) {
9+
// adds prefixes for firefox, chrome, safari, and opera regardless of version until a reliable brwoser support info can be found (see: https://github.com/rofrischmann/inline-style-prefixer/issues/79)
10+
if (
11+
property === 'cursor' && values[value] &&
12+
(
13+
browser === 'firefox' ||
14+
browser === 'chrome' ||
15+
browser === 'safari' ||
16+
browser === 'opera'
17+
)
18+
) {
19+
return {
20+
cursor: css + value + (keepUnprefixed ? ';' + camelToDashCase(property) + ':' + value : '')
21+
}
22+
}
23+
}
Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,7 @@ import camelToDashCase from '../utils/camelToDashCase'
22

33
const values = {
44
'zoom-in': true,
5-
'zoom-out': true,
6-
'grab': true,
7-
'grabbing': true
5+
'zoom-out': true
86
}
97

108
export default function cursor({ property, value, browserInfo: { browser, version }, prefix: { css }, keepUnprefixed }) {

modules/prefixProps.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

test/prefixer-test.js

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -150,13 +150,25 @@ describe('Resolving old 2012 flexbox specification', () => {
150150
})
151151
})
152152

153-
describe('Resolving special cursor values', () => {
154-
it('should add prefixes', () => {
153+
describe('Resolving zoom cursor values', () => {
154+
it('should add prefixes when appropriate', () => {
155155
const standard = { cursor: 'pointer' }
156156
const input = { cursor: 'zoom-in' }
157157
const output = { cursor: '-webkit-zoom-in' }
158158
expect(new Prefixer({ userAgent: Chrome14 }).prefix(standard)).to.eql(standard)
159159
expect(new Prefixer({ userAgent: Chrome14 }).prefix(input)).to.eql(output)
160+
expect(new Prefixer({ userAgent: Chrome49 }).prefix(input)).to.eql(input)
161+
})
162+
})
163+
164+
describe('Resolving grab cursor values', () => {
165+
it('should add prefixes when appropriate', () => {
166+
const standard = { cursor: 'pointer' }
167+
const input = { cursor: 'grab' }
168+
const output = { cursor: '-webkit-grab' }
169+
expect(new Prefixer({ userAgent: Chrome14 }).prefix(standard)).to.eql(standard)
170+
expect(new Prefixer({ userAgent: Chrome14 }).prefix(input)).to.eql(output)
171+
expect(new Prefixer({ userAgent: Chrome49 }).prefix(input)).to.eql(output)
160172
})
161173
})
162174

0 commit comments

Comments
 (0)