Bug Tracker

Ticket #900 (closed bug: fixed)

Opened 2 years ago

Last modified 1 year ago

get(0) or [0] on an empty resultset returns the document element

Reported by: zimbatm@… Assigned to: anonymous
Type: bug Priority: minor
Milestone: Component: core
Version: Keywords:
Cc: Needs:

Description

On the packed and unpacked version downloadable on jquery.com, you get the following inconsistent behaviour :

Lookup for an element that doesn't exist :

var x = $('#something') // => [ ]
x[0]                    // => Document
x.get(0)                // => Document

Here is the code I've used to reproduce the bug :


<html>

<head>

<title>Jquery bug</title> <script type="text/javascript" src="http://jquery.com/src/jquery-latest.pack.js"></script> <script type="text/javascript">

$(function() {

alert($('#kdjgldsg').get(0)); // should be null

})

</script>

</head> <body>

<h1>Hello world</h1>

</body>

</html>

Attachments

Change History

Changed 2 years ago by joern

  • status changed from new to closed
  • resolution set to fixed

Fixed some revisions ago, will be included in 1.1.2

Note: See TracTickets for help on using tickets.