Skip to content

Commit

Permalink
UserAgent giving NPE (#19481)
Browse files Browse the repository at this point in the history
* Adding null check for userAgent

* Change files

* Update packages/merge-styles/src/getVendorSettings.ts

Using optional chaining instead of ternary

Co-authored-by: David Zearing <dzearing@microsoft.com>

Co-authored-by: Arushi Jain <arujain@microsoft.com>
Co-authored-by: David Zearing <dzearing@microsoft.com>
  • Loading branch information
3 people authored Aug 24, 2021
1 parent 00df799 commit e6ee3ff
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"type": "patch",
"comment": "getVendorSettings.js file was leading to app crash if userAgent was null. Have added a null check for userAgent",
"packageName": "@fluentui/merge-styles",
"email": "arujain@microsoft.com",
"dependentChangeType": "patch"
}
2 changes: 1 addition & 1 deletion packages/merge-styles/src/getVendorSettings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ export function getVendorSettings(): IVendorSettings {
if (!_vendorSettings) {
const doc = typeof document !== 'undefined' ? document : undefined;
const nav = typeof navigator !== 'undefined' ? navigator : undefined;
const userAgent = nav ? nav.userAgent.toLowerCase() : undefined;
const userAgent = nav?.userAgent?.toLowerCase();

if (!doc) {
_vendorSettings = {
Expand Down

0 comments on commit e6ee3ff

Please sign in to comment.