Skip to content

Commit

Permalink
[jquery] scrollLeft() and scrollTop() can also return undefined.
Browse files Browse the repository at this point in the history
scrollLeft() and scrollTop() will return undefined when used on an empty set.
  • Loading branch information
leonard-thieu committed Jul 11, 2017
1 parent f5fd92f commit 1c6c4aa
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions types/jquery/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2845,7 +2845,7 @@ interface JQuery<TElement extends Node = HTMLElement> extends Iterable<TElement>
* @see {@link https://api.jquery.com/scrollLeft/}
* @since 1.2.6
*/
scrollLeft(): number;
scrollLeft(): number | undefined;
/**
* Set the current vertical position of the scroll bar for each of the set of matched elements.
*
Expand All @@ -2861,7 +2861,7 @@ interface JQuery<TElement extends Node = HTMLElement> extends Iterable<TElement>
* @see {@link https://api.jquery.com/scrollTop/}
* @since 1.2.6
*/
scrollTop(): number;
scrollTop(): number | undefined;
/**
* Bind an event handler to the "select" JavaScript event, or trigger that event on an element.
*
Expand Down
4 changes: 2 additions & 2 deletions types/jquery/jquery-tests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1936,15 +1936,15 @@ function JQuery() {
// $ExpectType JQuery<HTMLElement>
$('p').scrollLeft(200);

// $ExpectType number
// $ExpectType number | undefined
$('p').scrollLeft();
}

function scrollTop() {
// $ExpectType JQuery<HTMLElement>
$('p').scrollTop(200);

// $ExpectType number
// $ExpectType number | undefined
$('p').scrollTop();
}

Expand Down

0 comments on commit 1c6c4aa

Please sign in to comment.