[csswg-drafts] [scroll-animations] `ScrollTimeline` constructor has contradictory IDL and prose (#11340)

graouts has just created a new issue for https://github.com/w3c/csswg-drafts:

== [scroll-animations] `ScrollTimeline` constructor has contradictory IDL and prose  ==
The [`ScrollTimeline` IDL](https://drafts.csswg.org/scroll-animations-1/#scrolltimeline) reads as follows:

```
dictionary ScrollTimelineOptions {
  Element? source;
  ScrollAxis axis = "block";
};

[Exposed=Window]
interface ScrollTimeline : AnimationTimeline {
  constructor(optional ScrollTimelineOptions options = {});
};
```

And its [specification text](https://drafts.csswg.org/scroll-animations-1/#dom-scrolltimeline-scrolltimeline) is:

> 1. Let timeline be the new [ScrollTimeline](https://drafts.csswg.org/scroll-animations-1/#scrolltimeline) object.
> 2. Set the [source](https://drafts.csswg.org/scroll-animations-1/#dom-scrolltimeline-source) of timeline to:
> - If the source member of options is present and not null,
>     The source member of options.
> - Otherwise,
>     The [scrollingElement](https://drafts.csswg.org/cssom-view-1/#dom-document-scrollingelement) of the [Document](https://dom.spec.whatwg.org/#document) [associated](https://html.spec.whatwg.org/multipage/window-object.html#concept-document-window) with the [Window](https://html.spec.whatwg.org/multipage/nav-history-apis.html#window) that is the [current global object](https://html.spec.whatwg.org/multipage/webappapis.html#current-global-object).

To me, the IDL and the spec text are contradictory. Since the constructor is specified as taking `optional ScrollTimelineOptions options = {}` then I don't think we can distinguish between `ScrollTimeline` being constructed without an `options` parameter or with `{ source: null }`. But I believe the spec text is actually trying to distinguish between three cases:

1. `{}` where the source would be set to `document.scrollingElement`,
2. `{ source: null }` where the source would not be set,
3. `{ source: document.body }` where the source would be set to `document.body`.

At least this is what is being tested by the WPT test [scroll-animations/scroll-timelines/constructor.html](https://github.com/web-platform-tests/wpt/blob/master/scroll-animations/scroll-timelines/constructor.html).

Please view or discuss this issue at https://github.com/w3c/csswg-drafts/issues/11340 using your GitHub account


-- 
Sent via github-notify-ml as configured in https://github.com/w3c/github-notify-ml-config

Received on Monday, 9 December 2024 21:28:36 UTC