From 656ed686e53a8b93b25f151d859f9a8db0399353 Mon Sep 17 00:00:00 2001 From: Johannes Odland Date: Thu, 8 Feb 2024 20:29:46 +0100 Subject: [PATCH] Return unresolved current time for unattached source --- src/scroll-timeline-base.js | 2 +- test/expected.txt | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/scroll-timeline-base.js b/src/scroll-timeline-base.js index 702f346..2c85492 100644 --- a/src/scroll-timeline-base.js +++ b/src/scroll-timeline-base.js @@ -457,7 +457,7 @@ export class ScrollTimeline { get currentTime() { const unresolved = null; const container = this.source; - if (!container) return unresolved; + if (!container || !container.isConnected) return unresolved; if (this.phase == 'inactive') return unresolved; const scrollerStyle = getComputedStyle(container); diff --git a/test/expected.txt b/test/expected.txt index c045d1d..2382c52 100644 --- a/test/expected.txt +++ b/test/expected.txt @@ -690,7 +690,7 @@ PASS /scroll-animations/scroll-timelines/constructor.html 'y' is a valid axis va PASS /scroll-animations/scroll-timelines/constructor.html Creating a ScrollTimeline with an invalid axis value should throw PASS /scroll-animations/scroll-timelines/current-time-nan.html currentTime should be null for a display: inline source PASS /scroll-animations/scroll-timelines/current-time-nan.html currentTime should be null for a display: none source -FAIL /scroll-animations/scroll-timelines/current-time-nan.html currentTime should be null for an unattached source +PASS /scroll-animations/scroll-timelines/current-time-nan.html currentTime should be null for an unattached source PASS /scroll-animations/scroll-timelines/current-time-nan.html currentTime should be null when the source is not a scroller PASS /scroll-animations/scroll-timelines/current-time-root-scroller.html currentTime calculates the correct time for a document.scrollingElement source PASS /scroll-animations/scroll-timelines/current-time-writing-modes.html currentTime handles direction: rtl correctly