Skip to main content

Bug Tracker

Side navigation

#8391 closed bug (duplicate)

Opened February 26, 2011 11:43AM UTC

Closed February 28, 2011 11:23AM UTC

Last modified February 28, 2011 05:23PM UTC

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

Reported by: fred.mol@gmail.com 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/

Attachments (0)
Change History (5)

Changed February 27, 2011 02:02AM UTC by dmethvin comment:1

status: newopen

Yep, seems inconsistent.

Changed February 27, 2011 09:27PM UTC by dmethvin comment:2

component: unfiledattributes
milestone: 1.next1.6
priority: undecidedlow

Changed February 28, 2011 11:23AM UTC by jitter comment:3

component: attributesoffset
milestone: 1.61.next
priority: lowhigh
resolution: → duplicate
status: openclosed

Changed February 28, 2011 11:23AM UTC by jitter comment:4

Duplicate of #7931.

Changed February 28, 2011 05:23PM UTC by anonymous comment:5

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