Skip to content

[cssom-view] Should the associated element to window.scroll() be the scrollingElement? #2977

@fred-wang

Description

@fred-wang

The associated element is used to determine the scroll behavior when the one in ScrollOptions is auto ( https://drafts.csswg.org/cssom-view/#perform-a-scroll ). For window.scroll(), it is defined as the document’s root element ( https://drafts.csswg.org/cssom-view/#dom-window-scroll ):

Perform a scroll of the viewport to position, document’s root element as the associated element, if there is one, or null otherwise, and the scroll behavior being the value of the behavior dictionary member of options.

However, window.scroll() is also executed during Element.scroll() for two cases (steps 8 and 9), essentially when the function is invoked on the scrollingElement ( https://drafts.csswg.org/cssom-view/#dom-element-scroll ):

If the element is the root element invoke scroll() on window with scrollX on window as first argument and y as second argument, and terminate these steps.
If the element is the HTML body element, document is in quirks mode, and the element is not potentially scrollable, invoke scroll() on window with options as the only argument, and terminate these steps.

One could expect that the CSS scroll-behavior is taken from the element on which scroll() is called, which is not the true in the latter case. Should window.scroll() use the scrollingElement as an associated element instead?


Note: Other places where document’s root element is used are:
https://drafts.csswg.org/cssom-view/#scroll-to-the-beginning-of-the-document
https://drafts.csswg.org/cssom-view/#scroll-an-element-into-view

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions