Commit 552f3b43 authored by Prateek Bhatnagar's avatar Prateek Bhatnagar Committed by Joe Haddad

fixing observing paint types in safari bug (#10076)

* fixing observing paint types in safari bug

* using try catch for performanceObserver fallback
Co-authored-by: 's avatarJoe Haddad <timer150@gmail.com>
parent 3aa6edb6
...@@ -292,19 +292,19 @@ function renderReactElement(reactEl, domEl) { ...@@ -292,19 +292,19 @@ function renderReactElement(reactEl, domEl) {
} }
if (onPerfEntry && ST) { if (onPerfEntry && ST) {
if (!('PerformanceObserver' in window)) { try {
window.addEventListener('load', () => {
performance.getEntriesByType('paint').forEach(onPerfEntry)
})
} else {
performance.getEntriesByType('paint').forEach(onPerfEntry)
// Start an observer to catch any paint metrics which may fire _after_
// the load event is fired on the window
const observer = new PerformanceObserver(list => { const observer = new PerformanceObserver(list => {
list.getEntries().forEach(onPerfEntry) list.getEntries().forEach(onPerfEntry)
}) })
observer.observe({ entryTypes: ['paint'] }) // Start observing paint entry types.
observer.observe({
type: 'paint',
buffered: true,
})
} catch (e) {
window.addEventListener('load', () => {
performance.getEntriesByType('paint').forEach(onPerfEntry)
})
} }
} }
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment