Modify ↓
Ticket #7931 (closed bug: fixed)
scrollTop and scrollLeft setters return null when called on empty jquery object
| Reported by: | anonymous | Owned by: | Xavi- |
|---|---|---|---|
| Priority: | high | Milestone: | 1.6 |
| Component: | offset | Version: | 1.4.4 |
| Keywords: | Cc: | ||
| Blocking: | Blocked by: |
Description
Both the $.fn.scrollTop and $.fn.scrollLeft setters return null when called on an empty jquery object. This leads to unexpected null pointer exceptions. Example:
// Causes null pointer exception $(".does-not-exists").scrollTop(100).addClass("scrolled");
This is also inconsistant behavior. Most jquery setters (e.g. height, width, addClass, attr, css, etc...) always return jquery objects.
Change History
Please follow the bug reporting guidlines and use jsFiddle when providing test cases and demonstrations instead of pasting the code in the ticket.
Note: See
TracTickets for help on using
tickets.

Here's the pull request: https://github.com/jquery/jquery/pull/171