Bug Tracker

Opened 8 years ago

Closed 8 years ago

Last modified 8 years ago

#10403 closed bug (invalid)

elem.ownerDocument.defaultView throws an "Undefined" Error

Reported by: mppatterson15@… Owned by: mppatterson15@…
Priority: low Milestone: None
Component: css Version: 1.6.4
Keywords: Cc:
Blocked by: Blocking:

Description

Hi all, please forgive my lack of familiarity with the jQuery code, but I have found a possible bug when trying to use the NivoSlider Plugin. Although I encountered this bug when trying to use the plugin, I believe the error lies in the jQuery code. BR][[BR? When initializing NivoSlider, I received the following error:

Uncaught TypeError: Cannot read property 'defaultView' of undefined

After digging through the jQuery code, I narrowed the issue down to line 6566:

if ( !(defaultView = elem.ownerDocument.defaultView) ) {
    return undefined;
}

I assumed that it was trying to obtain defaultView from elem.ownerDocument, even though "elem" or "elem.ownerDocument" may not exist. I changed the condition to the following:

if ( typeof elem === 'undefined' || typeof elem.ownerDocument === 'undefined' || !(defaultView = elem.ownerDocument.defaultView) ) {
      return undefined;
}       

... and everything works as expected. No errors, and the plugin works perfectly. I do not consider my code to be an elegant solution, but it may point you in the right direction if you determine this to be an error with jQuery.
Worth noting is that the error appeared in Chrome 14.0.835.186, but not in Firefox 3.6.10. I did not test in any version of IE.
Thank you for your time, and thank you for such an amazing library. P.S: the copyright on jquery.com says "2010" - may want to fix that.

Change History (7)

comment:1 Changed 8 years ago by timmywil

Component: unfiledcss
Owner: set to mppatterson15@…
Priority: undecidedlow
Status: newpending

Thanks for taking the time to contribute to the jQuery project! Please provide a complete reduced test case on jsFiddle to help us assess your ticket.

Additionally, be sure to test against the jQuery Edge version to ensure the issue still exists. To get you started, use this boilerplate: http://jsfiddle.net/FrKyN/ Open the link and click to "Fork" (in the top menu) to get started.

comment:2 Changed 8 years ago by trac-o-bot

Resolution: invalid
Status: pendingclosed

Because we get so many tickets, we often need to return them to the initial reporter for more information. If that person does not reply within 14 days, the ticket will automatically be closed, and that has happened in this case. If you still are interested in pursuing this issue, feel free to add a comment with the requested information and we will be happy to reopen the ticket if it is still valid. Thanks!

comment:3 in reply to:  2 Changed 8 years ago by geoff@…

Replying to trac-o-bot:

Because we get so many tickets, we often need to return them to the initial reporter for more information. If that person does not reply within 14 days, the ticket will automatically be closed, and that has happened in this case. If you still are interested in pursuing this issue, feel free to add a comment with the requested information and we will be happy to reopen the ticket if it is still valid. Thanks!

This is the same as Ticket #6865 and ticket #7836, all of which have been closed. YET IT HAS JUST TRAPPED IN MY CODE, so I think all these tickets are valid, and the test should make sure elem.ownerDocument is valid before dereferencing it.

comment:4 Changed 8 years ago by mail.dwat001@…

I too am getting an error on this line. I am not using any jquery plugins.

jQuery Version:

jQuery 1.6.3 (same line of code, not sure if same line number) jQuery 1.6.4

Browsers:

Firefox 6.0.2 & 7.0.1 IE 9.0.8112 Chrome 14.0.835

Error message: elem.ownerDocument is undefined if ( !(defaultView = elem.ownerDocument.defaultView) ) { jquery-1.6.4.js (line 6566)

This can be reproduced at the following URL

http://jsfiddle.net/dwat001/SYQJA/19/show/

Steps to reproduce: Navigate to http://jsfiddle.net/dwat001/SYQJA/19/show/ click on a marker Mouse over photo in bottom of infoWindow Wait for larger photo to load & animate to full size, move mouse out of larger photo ERROR

I hope that gives you enough information to investigate this bug further.

comment:5 Changed 8 years ago by mail.dwat001@…

Follow up, I have just tried on jQuery version Edge and got a different error, I'm not sure this is before or after the above line of code is executed

The error I got was on line 1821

invalid 'in' operand thisCache

} else if ( name in thisCache ) {

Surrounding code:

Support space separated names if ( jQuery.isArray( name ) ) { name = name; } else if ( name in thisCache ) { name = [ name ]; } else { split the camel cased version by spaces

the variable thisCache === true

This is occurring IE,Chrome and Firefox

http://jsfiddle.net/dwat001/SYQJA/20/show/

comment:6 Changed 8 years ago by anonymous

What a bullshit: some user took the effort to log this bug, with a patch included and then the issue just gets auto-snubbed like that. Shame on you guys! I guess I will have to apply the patch myself to a local copy of the library. Thanks to the original poster for the detailed defect description.

comment:7 Changed 8 years ago by dmethvin

Honestly, guys. This is a bug tracker. Don't send us your broken code and then ask us to debug it, blaming jQuery for whatever programming mistake you have made. The test case above has this code:

    $("#floating-image").mouseleave( function(image){
        $(image)
            .stop()

An event handler is passed an event object as its first argument. Using the name image *does not magically turn it into an image*.

Note: See TracTickets for help on using tickets.