mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2026-08-11 12:30:18 +00:00
[jquery] offset() can return undefined on empty sets.
This commit is contained in:
Vendored
+1
-1
@@ -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.
|
||||
*
|
||||
|
||||
@@ -601,7 +601,7 @@ function JQuery() {
|
||||
};
|
||||
});
|
||||
|
||||
// $ExpectType Coordinates
|
||||
// $ExpectType Coordinates | undefined
|
||||
$('p').offset();
|
||||
}
|
||||
|
||||
|
||||
@@ -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 + ' )');
|
||||
|
||||
Reference in New Issue
Block a user