Bug Tracker

Opened 12 years ago

Closed 12 years ago

Last modified 12 years ago

#8391 closed bug (duplicate)

scrollTop, scrollLeft setters break chaining when selector doesn't match any elements

Reported by: [email protected] Owned by:
Priority: high Milestone: 1.next
Component: offset Version: 1.5.1
Keywords: Cc:
Blocked by: Blocking:


The following line throws a javascript error:


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 dmethvin

Status: newopen

Yep, seems inconsistent.

comment:2 Changed 12 years ago by dmethvin

Component: unfiledattributes
Milestone: 1.next1.6
Priority: undecidedlow

comment:3 Changed 12 years ago by jitter

Component: attributesoffset
Milestone: 1.61.next
Priority: lowhigh
Resolution: duplicate
Status: openclosed

comment:4 Changed 12 years ago by jitter

Duplicate of #7931.

comment:5 Changed 12 years ago by anonymous

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

Note: See TracTickets for help on using tickets.