jquery / jquery/api.jquery.com

Contradiction about outerWidth on window between API documentation and migration guide

Open
#1,199 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
HTML
Stars
325
Forks
260
PR merge metrics
No merged PRs in 30d

Description

outerwidth() documentation currently states:

This method is not applicable to window and document objects; for these, use .width() instead.

But the jQuery 3.0 migration guide states:

Breaking change: .outerWidth() or .outerHeight() on window includes scrollbar width/height

Calls to $(window).width() return the "content width" which excludes any scrollbars that the browser has added if the content exceeds the height of the element. This is different from the width that CSS uses for media queries, which includes the width of the scrollbars. In order to provide a measure that is equivalent to the CSS media query concept of width, the $(window).outerWidth() method now returns the width including scrollbar width. This is equivalent to the DOM property window.innerWidth. The same applies for .outerHeight().

So it seems to me either the API documentation is obsolete about outerWidth() not being applicable to window, or the migration guide is wrong telling us to call outerWidth() on window to get its "CSS width". This is confusing.

There is the same trouble with .outerHeight() documentation.

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

Read the outerWidth and outerHeight API documentation alongside the jQuery 3.0 migration guide section on window scrollbar dimensions. Determine which statements conflict and update the documentation so the behavior of these methods on window is described consistently with the migration guide. Confirm that both outerWidth() and outerHeight() are addressed.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript
Domain
documentation
Issue type
Documentation
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.