Skip to content

Commit

Permalink
#97 fixed windows phone fallback
Browse files Browse the repository at this point in the history
  • Loading branch information
rofrischmann committed Sep 14, 2016
1 parent 338a5a9 commit 8ae205e
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 19 deletions.
9 changes: 4 additions & 5 deletions generator/generateData.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ const browsers = [ 'chrome', 'safari', 'firefox', 'opera', 'ie', 'edge', 'ios_sa

function gatherInformation() {
const prefixProperties = { }
browsers.forEach(function (browser) {
browsers.forEach(function(browser) {
prefixProperties[browser] = { }
})

Expand All @@ -69,7 +69,7 @@ function gatherInformation() {
if (properties instanceof Array !== true) {
properties = [ properties ]
}
properties.forEach(function (prop) {
properties.forEach(function(prop) {
for (const prefix in prefixProperties) {
if (versions[prefix].x >= config[prefix]) {
prefixProperties[prefix][prop] = versions[prefix].x
Expand All @@ -78,16 +78,15 @@ function gatherInformation() {
})
}


prefixProperties.ie = assign({ }, prefixProperties.ie, prefixProperties.ie_mob)
delete prefixProperties.ie_mob
flexPropsIE.forEach(function (prop) {
flexPropsIE.forEach(function(prop) {
delete prefixProperties.ie[prop]
})
return 'export default ' + JSON.stringify(prefixProperties)
}

fs.writeFile('./modules/prefixProps.js', gatherInformation(), function (err) {
fs.writeFile('./modules/prefixProps.js', gatherInformation(), function(err) {
if (err) {
throw err
}
Expand Down
17 changes: 9 additions & 8 deletions modules/utils/getBrowserInformation.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,21 +8,21 @@ const browsers = {
chrome: [ [ 'chrome' ], [ 'chromium' ] ],
safari: [ [ 'safari' ] ],
firefox: [ [ 'firefox' ] ],
ie: [ [ 'msie' ] ],
edge: [ [ 'msedge' ] ],
opera: [ [ 'opera' ], [ 'vivaldi' ] ],
ios_saf: [ [ 'ios', 'mobile' ], [ 'ios', 'tablet' ] ],
ie_mob: [ [ 'windowsphone', 'mobile', 'msie' ], [ 'windowsphone', 'tablet', 'msie' ], [ 'windowsphone', 'mobile', 'msedge' ], [ 'windowsphone', 'tablet', 'msedge' ] ],
ie: [ [ 'msie' ] ],
op_mini: [ [ 'opera', 'mobile' ], [ 'opera', 'tablet' ] ],
and_uc: [ [ 'android', 'mobile' ], [ 'android', 'tablet' ] ],
android: [ [ 'android', 'mobile' ], [ 'android', 'tablet' ] ]
}

const browserByInfo = (info) => {
if (info['firefox']) {
return 'firefox';
const browserByInfo = info => {
if (info.firefox) {
return 'firefox'
}
let name = '';
let name = ''

Object.keys(browsers).forEach(browser => {
browsers[browser].forEach(condition => {
let match = 0
Expand All @@ -32,11 +32,12 @@ const browserByInfo = (info) => {
}
})
if (condition.length === match) {
name = browser;
name = browser
}
})
})
return name;

return name
}

/**
Expand Down
1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
"babel": "babel modules/ --out-dir lib",
"build": "npm run clean && mkdir dist && npm run babel && npm run generate && npm run dist",
"clean": "rimraf lib dist coverage",
"coverage": "codeclimate-test-reporter < coverage/lcov.info",
"dist": "cross-env NODE_ENV=production babel-node buildPackage && cross-env NODE_ENV=development babel-node buildPackage",
"generate": "babel-node generator/generateData.js",
"pretest": "npm run clean && npm run babel && npm run generate",
Expand Down
12 changes: 7 additions & 5 deletions test/prefixer-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ 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'

describe('Prefixing a property', () => {
it('should only add required prefixes', () => {
const input = { appearance: 'test', transition: 'test' }
Expand Down Expand Up @@ -45,6 +46,7 @@ describe('Prefixing a property', () => {
describe('Prefixing 2D transforms', () => {
const input = { transform: 'rotate(30deg)' }
const prefixed = { msTransform: 'rotate(30deg)' }

it('should be prefixed on IE 9', () => {
expect(new Prefixer({ userAgent: MSIE9 }).prefix(input)).to.eql(prefixed)
})
Expand All @@ -69,11 +71,11 @@ describe('Running on android < 4.4', () => {
expect(andPrefixer._browserInfo.version).to.eql(47)
})
it('Should use firefox version on android 4.2.2', () => {
const andPrefixer = new Prefixer({
userAgent: Android4_2_2Firefox48
})
expect(andPrefixer._browserInfo.osversion).to.eql(4.2)
expect(andPrefixer._browserInfo.version).to.eql(48)
const andPrefixer = new Prefixer({
userAgent: Android4_2_2Firefox48
})
expect(andPrefixer._browserInfo.osversion).to.eql(4.2)
expect(andPrefixer._browserInfo.version).to.eql(48)
})
})
describe('Running on iOS', () => {
Expand Down

0 comments on commit 8ae205e

Please sign in to comment.