Skip to main content

Bug Tracker

Side navigation

#8832 closed bug (invalid)

Opened April 09, 2011 03:34PM UTC

Closed April 10, 2011 09:31PM UTC

Last modified March 14, 2012 05:12PM UTC

in IE9 trying to access the zeroth element of an empty array causes failure - if this is an invalid bug why did it just happen to me I am trying to help you guys

Reported by: anonymous Owned by: anonymous
Priority: undecided Milestone:
Component: selector Version: 1.5.1
Keywords: Cc:
Blocked by: Blocking:

Sizzle.getText = function( elems ) {

var ret = "", elem;

for ( var i = 0; elems[i]; i++ ) {

elem = elems[i];

Attachments (0)
Change History (6)

Changed April 09, 2011 04:37PM UTC by rwaldron comment:1

component: unfiledselector
owner: → anonymous
status: newpending

Please use to provide a reduced test case that illustrates your issue.

Changed April 09, 2011 10:43PM UTC by anonymous comment:2

status: pendingnew

it is not MY issue. It is jQuery's issue

It does not need a test case

I am not a jQuery developer. I came across this in the wild and took the time and the trouble to tell you exactly where the problem is

I am not paid to provide documentation for your mistakes

Just look at the code. Anyone can see at a glance it is bad code.

A function receives an argument an just blindly uses it without first checking that is valid

Just fix it and quit messing aroung

Changed April 09, 2011 10:52PM UTC by anonymous comment:3

Having said that, the bug is real but I have mis-diagnosed it

Accessing an empty array is ok, but it must be that sometimes the array being passed in must not exist

Changed April 10, 2011 12:08AM UTC by timmywil comment:4

status: newpending

Thanks for your time and interest in helping out with the project! Asking for a test case is not meant to insult. We need testcases because we are all volunteering our time and there are a lot of tickets; as you can see from the ticket number, there have been over eight thousand eight hundred. Tickets with "instructions" don't necessarily lead to us creating the same circumstances as the OP. In this case, I don't see a bug or any use case being described. A jsfiddle test case would help us confirm there is actually a problem with Sizzle. Functions do not and should not always have to check the validity of their arguments.

Changed April 10, 2011 04:42PM UTC by anonymous comment:5

status: pendingnew

Your comment has a more reasonable tone

I think the mis-understanding is that bugs are probably most often reported by developers using jquery to develop web pages

I am not such a person. I do not develop using jquery and I have no interest in doing so. I am just a user whose web experience was affected negatively by this bug

I was surfing the web and the error occurred and the ie9 debugger highlighted that particulr code, so I thought I would let you know.

I want the web to be bug free no matter what technologies are used.

I cannot remember which site it occured on.

You are right and that not **all** functions need to check their arguments.

If function A is called and checks its arguments before passing them on to function B, then B has no need and indeed should not check them again

But some function somewhere should check the argument before trying to access properties on it

The error did occur and the debugger highlighted this code which is calling properties on an object which the function does not know exists, so it seems a reasonable assumption that the debugger is correct

So you have at least one site (not in developement but actually already out in the real world) which is causing this function to fail, and thereby reflecting badly on a library that, as you say, you are giving of your time to maintain and therefore must care about

As a maintainer I assume you know jquery well. In that case I would guess it would take a few seconds for you to create some code which results in this getText function being called with its argument being null or undefined

Checking the argument exists before accessing its properties seems a quick and easy protection against failure. It would probably have been quicker to fix the code than to reply to my comment

As I say, it is not my problem, and I don't care if it gets fixed or not apart from the very general desire that the web provides an error free user experience

Changed April 10, 2011 09:31PM UTC by timmywil comment:6

resolution: → invalid
status: newclosed

Thank you again. We appreciate everyone who contributes to improving jQuery. Closing this ticket until a more specific bug arises.