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

@mathiasbynens sure, that makes sense. Thanks for walking me through it. I'll state my case one last time, and then be done with it :-)

I suppose that my main objection is simply that I'd prefer to just feature detect that this bug is fixed, and go on my merry way of behaving the way the spec is written, rather than augmenting the spec to including an additional reference (even though it changes based on quirks mode or not) to either `document.documentElement` or `document.body`. Seems like less to have to change in the future, and less confusing for future web authors who never use quirks mode, and never developed during a time in which this bug existed, as to why there are 2 properties referencing document.documentElement.

If I have a simple boolean property, I can just replace `/* whatever UA check they use now */;` with `document.behavesCorrectly || /* whatever UA check they use now */;`

In closure, the change would be:

```
goog.dom.getDocumentScrollElement_ = function(doc) {
  // WebKit needs body.scrollLeft in both quirks mode and strict mode. We also
  // default to the documentElement if the document does not have a body (e.g.
  // a SVG document).
  if (!goog.userAgent.WEBKIT && goog.dom.isCss1CompatMode_(doc)) {
    return doc.documentElement;
  }
  return doc.body || doc.documentElement;
};
```

to:

```
goog.dom.getDocumentScrollElement_ = function(doc) {
  // WebKit needs body.scrollLeft in both quirks mode and strict mode. We also
  // default to the documentElement if the document does not have a body (e.g.
  // a SVG document).
  if ((!goog.userAgent.WEBKIT || document.behavesCorrectly) && goog.dom.isCss1CompatMode_(doc)) {
    return doc.documentElement;
  }
  return doc.body || doc.documentElement;
};
```

as opposed to:

```
goog.dom.getDocumentScrollElement_ = function(doc) {
  if ("scrollingElement" in document) {
    return document.scrollingElement;
  }
  // WebKit needs body.scrollLeft in both quirks mode and strict mode. We also
  // default to the documentElement if the document does not have a body (e.g.
  // a SVG document).
  if (!goog.userAgent.WEBKIT && goog.dom.isCss1CompatMode_(doc)) {
    return doc.documentElement;
  }
  return doc.body || doc.documentElement;
};
```

In the end, I commend @RByers for pushing this towards actually getting addressed, and I'm happy with whichever solution ends up happening here. Just wanted to make sure the case was made for alternate approaches.

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

Received on Friday, 24 April 2015 02:21:27 UTC