#8391 closed bug (duplicate)
scrollTop, scrollLeft setters break chaining when selector doesn't match any elements
Reported by: | Owned by: | ||
---|---|---|---|
Priority: | high | Milestone: | 1.next |
Component: | offset | Version: | 1.5.1 |
Keywords: | Cc: | ||
Blocked by: | Blocking: |
Description
The following line throws a javascript error:
$('.does-not-exist').scrollTop(0).scrollLeft(0);
The reason is that both scrollTop and scrollLeft always return null when the selector doesn't match any elements. They should only return null when used as getter (i.e. called without any arguments) Test case: http://jsfiddle.net/QZ6nH/1/
Change History (5)
comment:1 Changed 12 years ago by
Status: | new → open |
---|
comment:2 Changed 12 years ago by
Component: | unfiled → attributes |
---|---|
Milestone: | 1.next → 1.6 |
Priority: | undecided → low |
comment:3 Changed 12 years ago by
Component: | attributes → offset |
---|---|
Milestone: | 1.6 → 1.next |
Priority: | low → high |
Resolution: | → duplicate |
Status: | open → closed |
comment:5 Changed 12 years ago by
Here's a pull request with the fix: https://github.com/jquery/jquery/pull/171
Note: See
TracTickets for help on using
tickets.
Yep, seems inconsistent.