Skip to content

Commit

Permalink
fix(css-load): fix useCssLoadPatch determination when encountering un…
Browse files Browse the repository at this point in the history
…known UA strings

Requires rebuild post-merge.

Fixes ocombe#416
  • Loading branch information
booleanbetrayal authored Feb 5, 2018
1 parent c282f8f commit 2bfe646
Showing 1 changed file with 20 additions and 16 deletions.
36 changes: 20 additions & 16 deletions src/ocLazyLoad.loaders.common.js
Original file line number Diff line number Diff line change
Expand Up @@ -88,22 +88,26 @@
if(!uaCssChecked) {
var ua = $window.navigator.userAgent.toLowerCase();

if (ua.indexOf('phantomjs/1.9') > -1) {
// PhantomJS ~1.9
useCssLoadPatch = true;
} else if (/iP(hone|od|ad)/.test($window.navigator.platform)) {
// iOS < 6
var v = $window.navigator.appVersion.match(/OS (\d+)_(\d+)_?(\d+)?/);
var iOSVersion = parseFloat([parseInt(v[1], 10), parseInt(v[2], 10), parseInt(v[3] || 0, 10)].join('.'));
useCssLoadPatch = iOSVersion < 6;
} else if (ua.indexOf('android') > -1) {
// Android < 4.4
var androidVersion = parseFloat(ua.slice(ua.indexOf('android') + 8));
useCssLoadPatch = androidVersion < 4.4;
} else if (ua.indexOf('safari') > -1) {
// Safari < 6
var versionMatch = ua.match(/version\/([\.\d]+)/i);
useCssLoadPatch = (versionMatch && versionMatch[1] && parseFloat(versionMatch[1]) < 6);
try {
if (ua.indexOf('phantomjs/1.9') > -1) {
// PhantomJS ~1.9
useCssLoadPatch = true;
} else if (/iP(hone|od|ad)/.test($window.navigator.platform)) {
// iOS < 6
var v = $window.navigator.appVersion.match(/OS (\d+)_(\d+)_?(\d+)?/);
var iOSVersion = parseFloat([parseInt(v[1], 10), parseInt(v[2], 10), parseInt(v[3] || 0, 10)].join('.'));
useCssLoadPatch = iOSVersion < 6;
} else if (ua.indexOf('android') > -1) {
// Android < 4.4
var androidVersion = parseFloat(ua.slice(ua.indexOf('android') + 8));
useCssLoadPatch = androidVersion < 4.4;
} else if (ua.indexOf('safari') > -1) {
// Safari < 6
var versionMatch = ua.match(/version\/([\.\d]+)/i);
useCssLoadPatch = (versionMatch && versionMatch[1] && parseFloat(versionMatch[1]) < 6);
}
} catch (e) {
useCssLoadPatch = false;
}
}

Expand Down

0 comments on commit 2bfe646

Please sign in to comment.