Skip to content

Commit

Permalink
fix navigation type for safari 10
Browse files Browse the repository at this point in the history
  • Loading branch information
joetannenbaum committed Jan 15, 2025
1 parent 24f40c8 commit f673747
Showing 1 changed file with 16 additions and 4 deletions.
20 changes: 16 additions & 4 deletions packages/core/src/navigationType.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,23 @@ class NavigationType {
protected type: NavigationTimingType

public constructor() {
if (typeof window !== 'undefined' && window?.performance.getEntriesByType('navigation').length > 0) {
this.type = (window.performance.getEntriesByType('navigation')[0] as PerformanceNavigationTiming).type
} else {
this.type = 'navigate'
this.type = this.resolveType()
}

protected resolveType(): NavigationTimingType {
if (typeof window === 'undefined') {
return 'navigate'
}

if (
window.performance &&
window.performance.getEntriesByType &&
window.performance.getEntriesByType('navigation').length > 0
) {
return (window.performance.getEntriesByType('navigation')[0] as PerformanceNavigationTiming).type
}

return 'navigate'
}

public get(): NavigationTimingType {
Expand Down

0 comments on commit f673747

Please sign in to comment.