Skip to content

Commit

Permalink
fix: 兼容性问题, 数据includes换成indexOf
Browse files Browse the repository at this point in the history
  • Loading branch information
linxiaodi committed Nov 4, 2021
1 parent 5b1f184 commit b2eb753
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion packages/web-performance/src/lib/observe.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { PerformanceEntryHandler } from '../types'

const observe = (type: string, callback: PerformanceEntryHandler): PerformanceObserver | undefined => {
try {
if (PerformanceObserver.supportedEntryTypes.includes(type)) {
if (PerformanceObserver.supportedEntryTypes.indexOf(type) > -1) {
const po: PerformanceObserver = new PerformanceObserver((l) => l.getEntries().map(callback))

po.observe({ type, buffered: true })
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ const getNavigationTiming = (): Promise<IPerformanceNavigationTiming> | undefine
}

return new Promise((resolve) => {
if (isPerformanceObserverSupported() && PerformanceObserver.supportedEntryTypes.includes('navigation')) {
if (isPerformanceObserverSupported() && PerformanceObserver.supportedEntryTypes.indexOf('navigation') > -1) {
const entryHandler = (entry: PerformanceNavigationTiming) => {
if (entry.entryType === 'navigation') {
if (po) {
Expand Down
2 changes: 1 addition & 1 deletion packages/web-performance/src/utils/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ export const isIncludeArr = (arr1: Array<string>, arr2: Array<string>): boolean
}

for (let i = 0; i < arr1.length; i++) {
if (!arr2.includes(arr1[i])) {
if (!(arr2.indexOf(arr1[i]) > -1)) {
return false
}
}
Expand Down

0 comments on commit b2eb753

Please sign in to comment.