Skip to content

Commit

Permalink
simplify isSafariBrowser
Browse files Browse the repository at this point in the history
  • Loading branch information
slavaleleka committed Jan 27, 2023
1 parent 1d17016 commit c339a90
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 5 deletions.
4 changes: 1 addition & 3 deletions src/common/utils/user-agents.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,7 @@ const SAFARI_USER_AGENT_REGEXP = /\sVersion\/(\d{2}\.\d)(.+\s|\s)(Safari)\//;
*
* @returns True for Safari browser.
*/
export const isSafariBrowser = (userAgent: string): boolean => {
return SAFARI_USER_AGENT_REGEXP.test(userAgent);
};
export const isSafariBrowser = SAFARI_USER_AGENT_REGEXP.test(navigator.userAgent);

/**
* Checks whether the browser userAgent is supported.
Expand Down
2 changes: 1 addition & 1 deletion src/extended-css/helpers/event-tracker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ export class EventTracker {
* Creates new EventTracker.
*/
constructor() {
this.trackedEvents = isSafariBrowser(navigator.userAgent)
this.trackedEvents = isSafariBrowser
? SUPPORTED_EVENTS.filter((event) => !SAFARI_PROBLEMATIC_EVENTS.includes(event))
: SUPPORTED_EVENTS;

Expand Down
2 changes: 1 addition & 1 deletion src/selector/utils/absolute-matcher.ts
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ const normalizePropertyValue = (propertyName: string, propertyValue: string): st
break;
case CssProperty.Opacity:
// https://bugs.webkit.org/show_bug.cgi?id=93445
normalized = isSafariBrowser(navigator.userAgent)
normalized = isSafariBrowser
? (Math.round(parseFloat(propertyValue) * 100) / 100).toString()
: propertyValue;
break;
Expand Down

0 comments on commit c339a90

Please sign in to comment.