Protect from no IntersectionObserver while SSR (#206)

This commit is contained in:
Eric Eastwood 2023-05-02 00:28:10 -05:00 committed by GitHub
parent f3318446f8
commit 8bea5e0355
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 30 additions and 26 deletions

View File

@ -130,6 +130,9 @@ class TimeSelectorView extends TemplateView {
} }
); );
// Avoid an error when server-side rendering (SSR) because it doesn't have all the
// DOM API's available (and doesn't need it for this case)
if (typeof IntersectionObserver === 'function') {
// Since this lives in the right-panel which is conditionally hidden from view with // Since this lives in the right-panel which is conditionally hidden from view with
// `display: none;`, we have to re-evaluate the scrubber scroll position when it // `display: none;`, we have to re-evaluate the scrubber scroll position when it
// becomes visible because client dimensions evaluate to `0` when something is // becomes visible because client dimensions evaluate to `0` when something is
@ -157,6 +160,7 @@ class TimeSelectorView extends TemplateView {
}); });
} }
); );
}
const timeInput = t.input({ const timeInput = t.input({
type: 'time', type: 'time',