From 387df2bca9acb3ab29a3b242106ded1399348c4f Mon Sep 17 00:00:00 2001 From: Johannes Odland Date: Mon, 12 Feb 2024 21:03:08 +0100 Subject: [PATCH] Pass idlharness.window.html --- src/init-polyfill.js | 4 ++-- src/scroll-timeline-base.js | 38 ++++++++++++++++++------------------- test/expected.txt | 24 ++++++++++++----------- 3 files changed, 33 insertions(+), 33 deletions(-) diff --git a/src/init-polyfill.js b/src/init-polyfill.js index e3dd471..2dd9598 100644 --- a/src/init-polyfill.js +++ b/src/init-polyfill.js @@ -32,14 +32,14 @@ export function initPolyfill() { } if ( - !Reflect.defineProperty(window, 'ScrollTimeline', { value: ScrollTimeline }) + !Reflect.defineProperty(window, 'ScrollTimeline', { value: ScrollTimeline, writable: true, configurable: true }) ) { throw Error( 'Error installing ScrollTimeline polyfill: could not attach ScrollTimeline to window' ); } if ( - !Reflect.defineProperty(window, 'ViewTimeline', { value: ViewTimeline }) + !Reflect.defineProperty(window, 'ViewTimeline', { value: ViewTimeline, writable: true, configurable: true }) ) { throw Error( 'Error installing ViewTimeline polyfill: could not attach ViewTimeline to window' diff --git a/src/scroll-timeline-base.js b/src/scroll-timeline-base.js index 2c85492..5911536 100644 --- a/src/scroll-timeline-base.js +++ b/src/scroll-timeline-base.js @@ -373,7 +373,7 @@ export function _getStlOptions(scrollTimeline) { } export class ScrollTimeline { - constructor(options) { + constructor(options = {}) { scrollTimelineOptions.set(this, { source: null, axis: DEFAULT_TIMELINE_AXIS, @@ -405,24 +405,10 @@ export class ScrollTimeline { updateInternal(this); } - set source(element) { - updateSource(this, element); - updateInternal(this); - } - get source() { return scrollTimelineOptions.get(this).source; } - set axis(axis) { - if (!isValidAxis(axis)) { - throw TypeError("Invalid axis"); - } - - scrollTimelineOptions.get(this).axis = axis; - updateInternal(this); - } - get axis() { return scrollTimelineOptions.get(this).axis; } @@ -480,6 +466,16 @@ export class ScrollTimeline { return true; } } +// Extend AnimationTimeline +Object.setPrototypeOf(ScrollTimeline, AnimationTimeline); +Object.setPrototypeOf(ScrollTimeline.prototype, AnimationTimeline.prototype); +// Set toStringTag +Object.defineProperty(ScrollTimeline.prototype, Symbol.toStringTag, {value: "ScrollTimeline" }); + +// Make properties enumerable +Object.defineProperty(ScrollTimeline.prototype, 'source', {enumerable: true, set: undefined}); +Object.defineProperty(ScrollTimeline.prototype, 'axis', {enumerable: true, set: undefined}); + // Methods for calculation of the containing block. // See https://developer.mozilla.org/en-US/docs/Web/CSS/Containing_block. @@ -826,7 +822,7 @@ export class ViewTimeline extends ScrollTimeline { // Proceeding under the assumption that subject will be added to // ViewTimelineOptions. Inferring the source from the subject if not // explicitly set. - constructor(options) { + constructor(options = {}) { super(options); const details = scrollTimelineOptions.get(this); details.subject = options && options.subject ? options.subject : undefined; @@ -855,10 +851,6 @@ export class ViewTimeline extends ScrollTimeline { return scrollTimelineOptions.get(this).source; } - set source(source) { - throw new Error("Cannot set the source of a view timeline"); - } - get subject() { return scrollTimelineOptions.get(this).subject; } @@ -893,3 +885,9 @@ export class ViewTimeline extends ScrollTimeline { } } + +// Make properties enumerable +Object.defineProperty(ViewTimeline.prototype, 'subject', {enumerable: true, set: undefined}); +Object.defineProperty(ViewTimeline.prototype, 'startOffset', {enumerable: true, set: undefined}); +Object.defineProperty(ViewTimeline.prototype, 'endOffset', {enumerable: true, set: undefined}); + diff --git a/test/expected.txt b/test/expected.txt index 003d769..fa237be 100644 --- a/test/expected.txt +++ b/test/expected.txt @@ -696,6 +696,7 @@ PASS /scroll-animations/scroll-timelines/current-time-root-scroller.html current PASS /scroll-animations/scroll-timelines/current-time-writing-modes.html currentTime handles direction: rtl correctly PASS /scroll-animations/scroll-timelines/current-time-writing-modes.html currentTime handles writing-mode: vertical-rl correctly PASS /scroll-animations/scroll-timelines/current-time-writing-modes.html currentTime handles writing-mode: vertical-lr correctly +PASS /scroll-animations/scroll-timelines/duration.html The duration of a scroll timeline is 100% PASS /scroll-animations/scroll-timelines/effect-updateTiming.html Allows setting the delay to a positive number PASS /scroll-animations/scroll-timelines/effect-updateTiming.html Allows setting the delay to a negative number PASS /scroll-animations/scroll-timelines/effect-updateTiming.html Allows setting the delay of an animation in progress: positive delay that causes the animation to be no longer in-effect @@ -791,27 +792,27 @@ PASS /scroll-animations/scroll-timelines/idlharness.window.html Element includes PASS /scroll-animations/scroll-timelines/idlharness.window.html Element includes NonDocumentTypeChildNode: member names are unique PASS /scroll-animations/scroll-timelines/idlharness.window.html Element includes ChildNode: member names are unique PASS /scroll-animations/scroll-timelines/idlharness.window.html Element includes Slottable: member names are unique -FAIL /scroll-animations/scroll-timelines/idlharness.window.html ScrollTimeline interface: existence and properties of interface object -FAIL /scroll-animations/scroll-timelines/idlharness.window.html ScrollTimeline interface object length +PASS /scroll-animations/scroll-timelines/idlharness.window.html ScrollTimeline interface: existence and properties of interface object +PASS /scroll-animations/scroll-timelines/idlharness.window.html ScrollTimeline interface object length PASS /scroll-animations/scroll-timelines/idlharness.window.html ScrollTimeline interface object name -FAIL /scroll-animations/scroll-timelines/idlharness.window.html ScrollTimeline interface: existence and properties of interface prototype object +PASS /scroll-animations/scroll-timelines/idlharness.window.html ScrollTimeline interface: existence and properties of interface prototype object PASS /scroll-animations/scroll-timelines/idlharness.window.html ScrollTimeline interface: existence and properties of interface prototype object's "constructor" property PASS /scroll-animations/scroll-timelines/idlharness.window.html ScrollTimeline interface: existence and properties of interface prototype object's @@unscopables property -FAIL /scroll-animations/scroll-timelines/idlharness.window.html ScrollTimeline interface: attribute source -FAIL /scroll-animations/scroll-timelines/idlharness.window.html ScrollTimeline interface: attribute axis +PASS /scroll-animations/scroll-timelines/idlharness.window.html ScrollTimeline interface: attribute source +PASS /scroll-animations/scroll-timelines/idlharness.window.html ScrollTimeline interface: attribute axis PASS /scroll-animations/scroll-timelines/idlharness.window.html ScrollTimeline must be primary interface of new ScrollTimeline() -FAIL /scroll-animations/scroll-timelines/idlharness.window.html Stringification of new ScrollTimeline() +PASS /scroll-animations/scroll-timelines/idlharness.window.html Stringification of new ScrollTimeline() PASS /scroll-animations/scroll-timelines/idlharness.window.html ScrollTimeline interface: new ScrollTimeline() must inherit property "source" with the proper type PASS /scroll-animations/scroll-timelines/idlharness.window.html ScrollTimeline interface: new ScrollTimeline() must inherit property "axis" with the proper type -FAIL /scroll-animations/scroll-timelines/idlharness.window.html ViewTimeline interface: existence and properties of interface object -FAIL /scroll-animations/scroll-timelines/idlharness.window.html ViewTimeline interface object length +PASS /scroll-animations/scroll-timelines/idlharness.window.html ViewTimeline interface: existence and properties of interface object +PASS /scroll-animations/scroll-timelines/idlharness.window.html ViewTimeline interface object length PASS /scroll-animations/scroll-timelines/idlharness.window.html ViewTimeline interface object name PASS /scroll-animations/scroll-timelines/idlharness.window.html ViewTimeline interface: existence and properties of interface prototype object PASS /scroll-animations/scroll-timelines/idlharness.window.html ViewTimeline interface: existence and properties of interface prototype object's "constructor" property PASS /scroll-animations/scroll-timelines/idlharness.window.html ViewTimeline interface: existence and properties of interface prototype object's @@unscopables property -FAIL /scroll-animations/scroll-timelines/idlharness.window.html ViewTimeline interface: attribute subject -FAIL /scroll-animations/scroll-timelines/idlharness.window.html ViewTimeline interface: attribute startOffset -FAIL /scroll-animations/scroll-timelines/idlharness.window.html ViewTimeline interface: attribute endOffset +PASS /scroll-animations/scroll-timelines/idlharness.window.html ViewTimeline interface: attribute subject +PASS /scroll-animations/scroll-timelines/idlharness.window.html ViewTimeline interface: attribute startOffset +PASS /scroll-animations/scroll-timelines/idlharness.window.html ViewTimeline interface: attribute endOffset PASS /scroll-animations/scroll-timelines/intrinsic-iteration-duration.tentative.html Computed duration in percent even when specified in ms FAIL /scroll-animations/scroll-timelines/intrinsic-iteration-duration.tentative.html Time-based duration normalized to fill animation range. PASS /scroll-animations/scroll-timelines/intrinsic-iteration-duration.tentative.html Time-based duration normalized to preserve proportional delays. @@ -1026,6 +1027,7 @@ PASS /scroll-animations/view-timelines/block-view-timeline-current-time.tentativ FAIL /scroll-animations/view-timelines/block-view-timeline-nested-subject.tentative.html View timeline with subject that is not a direct descendant of the scroll container FAIL /scroll-animations/view-timelines/change-animation-range-updates-play-state.html Changing the animation range updates the play state FAIL /scroll-animations/view-timelines/contain-alignment.html Stability of animated elements aligned to the bounds of a contain region +PASS /scroll-animations/view-timelines/duration.html The duration of a view timeline is 100% PASS /scroll-animations/view-timelines/fieldset-source.html Fieldset is a valid source for a view timeline FAIL /scroll-animations/view-timelines/get-keyframes-with-timeline-offset.html Report specified timeline offsets FAIL /scroll-animations/view-timelines/get-keyframes-with-timeline-offset.html Computed offsets can be outside [0,1] for keyframes with timeline offsets