w3c / w3c/csswg-drafts

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

Open
#2,977 3 comments 2 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

cssom-view-1
Dominant language
Bikeshed
Stars
4.9k
Forks
816
PR merge metrics
PR metrics pending

Description

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

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the CSSOM View sections linked in the issue, especially the window.scroll(), Element.scroll(), and associated-element algorithms. Compare the root-element and scrollingElement cases, then review the related document-scrolling algorithms; done requires a resolved specification decision and corresponding algorithm updates.

Written by the indexing model from the issue text.

Assessment

Tech stack
css
Domain
documentation, web-dev
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
30/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.