Bug Tracker

Opened 11 years ago

Closed 11 years ago

Last modified 10 years ago

#8832 closed bug (invalid)

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: 1.next
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];

Change History (6)

comment:1 Changed 11 years ago by Rick Waldron

Component: unfiledselector
Owner: set to anonymous
Status: newpending

Please use http://jsfiddle.net to provide a reduced test case that illustrates your issue.

comment:2 Changed 11 years ago by anonymous

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

comment:3 Changed 11 years ago by anonymous

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

comment:4 Changed 11 years ago by timmywil

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.

comment:5 Changed 11 years ago by anonymous

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

comment:6 Changed 11 years ago by timmywil

Resolution: invalid
Status: newclosed

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

Note: See TracTickets for help on using tickets.