Re: [spec-reviews] CSSOM View document.scrollingElement (#51)

So in the future, assuming the bug is successfully fixed, and you don't have to worry about current-era browsers, but still worry about quirks mode (like Closure does), with `scrollingElement` it would be like this:

```js
goog.dom.getDocumentScrollElement_ = function(doc) {
    return doc.scrollingElement;
}
```
(or scrap the method altogether and use `scrollingElement` directly)

with `behavesCorrectly` it would be (assuming it returns `false` in quirks mode?)

```js
goog.dom.getDocumentScrollElement_ = function(doc) {
    if (doc.behavesCorrectly) {
        return doc.documentElement;
    }
    return doc.body || doc.documentElement;
}
```
However this would not be technically correct (the current Closure script isn't, either), because `document.body` can be a `frameset` element, or the `body` can be independently scrollable (in which case, `scrollTop` should scroll the element, not the viewport, per spec), or if `document.body` is null it would give you the `html` element but that is not the "scrolling element" in quirks mode, and so on. Possibly being technically correct is a non-goal for Closure; it was a goal for the polyfill. With `scrollingElement` you get correct behavior "for free".

---
Reply to this email directly or view it on GitHub:
https://github.com/w3ctag/spec-reviews/issues/51#issuecomment-95837304

Received on Friday, 24 April 2015 07:47:38 UTC