Skip to content

Commit afd6b8a

Browse files
committed
Add method to check for WebKit WebView user agent string
1 parent f7c4692 commit afd6b8a

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

src/lib/index.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -765,6 +765,12 @@ lib.isIOS = function() {
765765
return IS_IOS_REGEX.test(window.navigator.userAgent);
766766
};
767767

768+
// The WKWebView user agent string doesn't include 'Safari', so we need a separate test
769+
// for a UA string like this:
770+
// Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/605.1.15 (KHTML, like Gecko)
771+
const IS_MAC_WKWEBVIEW_REGEX = /Macintosh.+AppleWebKit.+Gecko\)$/;
772+
lib.isMacWKWebView = () => IS_MAC_WKWEBVIEW_REGEX.test(window.navigator.userAgent);
773+
768774
var FIREFOX_VERSION_REGEX = /Firefox\/(\d+)\.\d+/;
769775
lib.getFirefoxVersion = function() {
770776
var match = FIREFOX_VERSION_REGEX.exec(window.navigator.userAgent);

src/lib/supports_pixelated_image.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ function supportsPixelatedImage() {
1919
_supportsPixelated = false;
2020

2121
// @see https://github.com/plotly/plotly.js/issues/6604
22-
var unsupportedBrowser = Lib.isSafari() || Lib.isIOS();
22+
var unsupportedBrowser = Lib.isSafari() || Lib.isMacWKWebView() || Lib.isIOS();
2323

2424
if(window.navigator.userAgent && !unsupportedBrowser) {
2525
var declarations = Array.from(constants.CSS_DECLARATIONS).reverse();

0 commit comments

Comments
 (0)