Skip to content

Contradiction about outerWidth on window between API documentation and migration guide #1199

Open
@fredericDelaporte

Description

@fredericDelaporte

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions