Skip to content

Commit ad0ec10

Browse files
authored
Update browsengine.js
1 parent 3b73d6f commit ad0ec10

File tree

1 file changed

+23
-14
lines changed

1 file changed

+23
-14
lines changed

src/browsengine.js

Lines changed: 23 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
* @version: 0.1.1
55
* @author: https://twitter.com/isocroft (@isocroft)
66
* @created: 13/11/2014
7-
* @updated: 05/06/2020
7+
* @updated: 06/19/2020
88
* @license: MIT
99
* @remarks: with love for the OpenSource Community...
1010
*
@@ -51,9 +51,9 @@ function has_pcredentials_iconurl(){
5151

5252
function actual_non_emulated_IE_major_version() {
5353
// Detects the actual version of IE in use, even if it's in an older-IE emulation mode.
54-
// IE JavaScript conditional compilation docs: https://msdn.microsoft.com/library/121hztk3%28v=vs.94%29.aspx
54+
// IE JavaScript conditional compilation ( @cc_on )
5555

56-
// @cc_on docs: https://msdn.microsoft.com/library/8ka90k2e%28v=vs.94%29.aspx
56+
// See: https://msdn.microsoft.com/library/8ka90k2e%28v=vs.94%29.aspx
5757

5858
var jscriptVersion = new Function('/*@cc_on return @_jscript_version; @*/')(); // jshint ignore:line
5959

@@ -210,9 +210,9 @@ contentLoaded.apply(null, [window, function(){
210210

211211
},
212212
isWebOS:function(bd){
213-
214-
// @See: http://ryanmorr.com/the-state-of-browser-detection/
215-
return (('PalmSystem' in w) && (ua.search(/(Web|HPW)OS/) > -1));
213+
214+
// @See: http://ryanmorr.com/the-state-of-browser-detection/
215+
return (('PalmSystem' in w) && (ua.search(/(Web|HPW)OS/) > -1));
216216

217217
}
218218
},
@@ -551,28 +551,37 @@ contentLoaded.apply(null, [window, function(){
551551

552552
}
553553

554-
w.isSafariAndiOS12OrLater = function(){
555-
return isSafWebkit && (typeof n.share === 'function' && typeof w['IntersectionObserver'] === 'function') && ();
554+
var isSafariAndiOS12OrLater = function(){
555+
return isSafWebkit && (typeof n.share === 'function' && typeof w['IntersectionObserver'] === 'function') && (String(w.IntersectionObserver) === 'function IntersectionObserver() { [native code] }');
556556
}
557557

558-
w.isOpera33OrLater = function(){
559-
return isBlink && !isPresto && (!!w.opr && !!w.opr.addons && typeof w.CSS.supports === 'function') && (String(w.caches) === '[object CacheStorage]');
558+
var isOpera33OrLater = function(){
559+
return isBlink && !isPresto && ((!!w.opr && !!w.opr.addons) && (!!w.CSS && typeof w.CSS.supports === 'function')) && (String(w.caches) === '[object CacheStorage]');
560560
}
561561

562-
w.isEdge17OrLater = function(){
562+
var isEdge17OrLater = function(){
563563
return (isEdgeChromium || isEdgeHTML) && (typeof w.PushManager === 'function') && (String(w.PushManager) === 'function PushManager() { [native code] }');
564564
}
565565

566-
w.isChrome40OrLater = function(){
566+
var isChrome40OrLater = function(){
567567
var i = d.createElement('input');
568568
return isChrWebkit && isChromiumBlink && (typeof i['reportValidity'] === 'function') && (String(i['reportValidity']) === 'function reportValidity() { [native code] }');
569569
}
570570

571-
w.isFirefox44OrLater = function(){
571+
var isFirefox44OrLater = function(){
572572
return isGecko && (typeof w.PushManager === 'function') && (String(w.PushManager) === 'function PushManager() {\n [native code]\n}');
573573
}
574574

575-
w.isSamsungInternet4OrLater = function(){ return false; }
575+
var isSamsungInternet4OrLater = function(){ return false; }
576+
577+
w.navigator.isSWCapable = function() {
578+
return isSafariAndiOS12OrLater()
579+
|| isOpera33OrLater()
580+
|| isEdge17OrLater()
581+
|| isChrome40OrLater()
582+
|| isFirefox44OrLater()
583+
|| isSamsungInternet4OrLater();
584+
};
576585

577586
/* retrieve browser build name (if any) */
578587

0 commit comments

Comments
 (0)