[jquery] offset() can return undefined on empty sets.

This commit is contained in:
Leonard Thieu
2017-06-26 08:00:00 -04:00
parent 8532f27673
commit 2ff6e2cad4
3 changed files with 4 additions and 4 deletions
+1 -1
View File
@@ -1368,7 +1368,7 @@ interface JQuery<TElement extends Node = HTMLElement> {
* @see {@link https://api.jquery.com/offset/}
* @since 1.2
*/
offset(): JQuery.Coordinates;
offset(): JQuery.Coordinates | undefined;
/**
* Get the closest ancestor element that is positioned.
*
+1 -1
View File
@@ -601,7 +601,7 @@ function JQuery() {
};
});
// $ExpectType Coordinates
// $ExpectType Coordinates | undefined
$('p').offset();
}
+2 -2
View File
@@ -3754,13 +3754,13 @@ function examples() {
function offset_0() {
var p = $('p:last');
var offset = p.offset();
var offset = p.offset()!;
p.html('left: ' + offset.left + ', top: ' + offset.top);
}
function offset_1() {
$('*', document.body).click(function(event) {
var offset = $(this).offset();
var offset = $(this).offset()!;
event.stopPropagation();
$('#result').text(this.tagName +
' coords ( ' + offset.left + ', ' + offset.top + ' )');