Skip to content

Commit 0f31358

Browse files
committed
Device.windowsPhone should now correctly identify Windows Phone 8.1 devices, which also think they are iOS and Androids. If you find a device that gets around this check please send us its ua string! (thanks @jounii phaserjs#1496)
1 parent f48d038 commit 0f31358

2 files changed

Lines changed: 13 additions & 8 deletions

File tree

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -423,6 +423,7 @@ Version 2.4 - "Katar" - in dev
423423
* Reading the dimensions of a Text object would reset its resolution property (thanks @joelika #1717)
424424
* Text.addColor would incorrectly color the text stroke if set (thanks @llevkin #1893)
425425
* Setting the scaleMode property of a Game configuration object would cause a ScaleManager TypeError in the resize method. It now stores the scale mode locally and applies it after boot (thanks @Mickawesomesque #1534)
426+
* Device.windowsPhone should now correctly identify Windows Phone 8.1 devices, which also think they are iOS and Androids. If you find a device that gets around this check please send us its ua string! (thanks @jounii #1496)
426427

427428
### Deprecated
428429

src/system/Device.js

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -670,11 +670,15 @@ Phaser.Device._initialize = function () {
670670
else if (/Windows/.test(ua))
671671
{
672672
device.windows = true;
673+
}
673674

674-
if (/Windows Phone/i.test(ua))
675-
{
676-
device.windowsPhone = true;
677-
}
675+
if (/Windows Phone/i.test(ua) || /IEMobile/i.test(ua))
676+
{
677+
device.android = false;
678+
device.iOS = false;
679+
device.macOS = false;
680+
device.windows = true;
681+
device.windowsPhone = true;
678682
}
679683

680684
var silk = /Silk/.test(ua); // detected in browsers
@@ -854,7 +858,7 @@ Phaser.Device._initialize = function () {
854858
{
855859
device.arora = true;
856860
}
857-
else if (/Chrome\/(\d+)/.test(ua))
861+
else if (/Chrome\/(\d+)/.test(ua) && !device.windowsPhone)
858862
{
859863
device.chrome = true;
860864
device.chromeVersion = parseInt(RegExp.$1, 10);
@@ -885,7 +889,7 @@ Phaser.Device._initialize = function () {
885889
{
886890
device.opera = true;
887891
}
888-
else if (/Safari/.test(ua))
892+
else if (/Safari/.test(ua) && !device.windowsPhone)
889893
{
890894
device.safari = true;
891895
}
@@ -897,13 +901,13 @@ Phaser.Device._initialize = function () {
897901
device.ieVersion = parseInt(RegExp.$3, 10);
898902
}
899903

900-
//Silk gets its own if clause because its ua also contains 'Safari'
904+
// Silk gets its own if clause because its ua also contains 'Safari'
901905
if (/Silk/.test(ua))
902906
{
903907
device.silk = true;
904908
}
905909

906-
// WebApp mode in iOS
910+
// WebApp mode in iOS
907911
if (navigator['standalone'])
908912
{
909913
device.webApp = true;

0 commit comments

Comments
 (0)