Skip to content

Commit

Permalink
fixed prefix sorting
Browse files Browse the repository at this point in the history
  • Loading branch information
rofrischmann committed Nov 26, 2016
1 parent 566dbcf commit 45f8566
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 3 deletions.
1 change: 1 addition & 0 deletions modules/static/prefixAll.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import prefixProperties from './prefixProps'
import capitalizeString from '../utils/capitalizeString'
import sortPrefixedStyle from '../utils/sortPrefixedStyle'

import position from './plugins/position'
import calc from './plugins/calc'
Expand Down
8 changes: 5 additions & 3 deletions modules/utils/sortPrefixedStyle.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
export function sortPrefixedStyle(style) {
import isPrefixedProperty from './isPrefixedProperty'

export default function sortPrefixedStyle(style) {
return Object.keys(style).sort((left, right) => {
if (isPrefixed(left) && !isPrefixed(right)) {
if (isPrefixedProperty(left) && !isPrefixedProperty(right)) {
return -1
} else if (!isPrefixed(left) && isPrefixed(right)) {
} else if (!isPrefixedProperty(left) && isPrefixedProperty(right)) {
return 1
}
return 0
Expand Down
3 changes: 3 additions & 0 deletions test/prefixer-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@ const Chrome49 = 'Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML,
const SeaMonkey = 'Mozilla/5.0 (Windows NT 5.2; RW; rv:7.0a1) Gecko/20091211 SeaMonkey/9.23a1pre'
const Chromium = 'Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Ubuntu Chromium/50.0.2661.102 Chrome/50.0.2661.102 Safari/537.36'
const PhantomJS = 'Mozilla/5.0 (Macintosh; Intel Mac OS X) AppleWebKit/538.1 (KHTML, like Gecko) PhantomJS/2.0.0 Safari/538.1'
const Samsung = 'Mozilla/5.0 (Linux; Android 6.0.1; SAMSUNG SM-G900F Build/MMB29M) AppleWebKit/537.36 (KHTML, like Gecko) SamsungBrowser/4.0 Chrome/44.0.2403.133 Mobile Safari/537.36'

console.log(new Prefixer({ userAgent: Samsung })._browserInfo)

describe('Prefixing a property', () => {
it('should only add required prefixes', () => {
Expand Down

0 comments on commit 45f8566

Please sign in to comment.