Ticket created: http://dev.jquery.com/ticket/4366
I'm not sure that this needs to be fixed, as opposed to documented, as was done with $.isFunction. It's obviously not a commonly used case. It would have saved me hours of head-beating if I had known that I had to write an old-fashioned for-loop or use $.each ($.makeArray (document.styleSheets)...; it's not hard. And John: "What a stupid behavior" and "part of IE" is redundant. Actually, it's understandable why this happens (not forgivable; Microsoft should have fixed it): for COM collections like styleSheets, the collection[i] notation is just syntactic sugar for collection.item (i), a function call. It's not unreasonable for a function call to throw an error for incorrect arguments. Microsoft lives in a .NET world, where arrays are arrays. This dynamic expando thing is beyond their little brains. Danny On Mar 17, 8:29 am, John Resig <[email protected]> wrote: > Would you be open to filing a bug on this? Thanks. > > What a stupid behavior on the part of IE. > > --John > > On Tue, Mar 17, 2009 at 3:35 AM, Danny <[email protected]> wrote: > > > $.each(document.styleSheets... fails with the error: > > Line: 692 > > Character: 11 > > Code: 0 > > Error Message: Invalid procedure call or argument > > > The simplest page with the error is: > > > <script type="text/javascript" src="http://ajax.googleapis.com/ajax/ > > libs/jquery/1.3.2/jquery.js<http://ajax.googleapis.com/ajax/%0Alibs/jquery/1.3.2/jquery.js>" > > ></script> > > <script> > > $.each (document.styleSheets, function(){}); > > </script> > > > (making the markup valid and adding a DOCTYPE don't help). > > > A regular for loop works fine. > > > It seems the problem is the object[++i] at the end of the loop; > > instead of returning undefined it throws the error. > > > Danny --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "jQuery Development" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/jquery-dev?hl=en -~----------~----~----~----~------~----~------~--~---
