Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ss.isVisible bug if elem==null #160

Closed
RCohenE5Group opened this issue Apr 13, 2016 · 2 comments
Closed

ss.isVisible bug if elem==null #160

RCohenE5Group opened this issue Apr 13, 2016 · 2 comments

Comments

@RCohenE5Group
Copy link

Hello
I use Simple Ajax Uploader Version 2.5.3 , and have the following error :

Uncaught TypeError: Cannot read property 'nodeType' of null SimpleAjaxUploader.js:389

In debug mode I find that elem.parentNode==null. I'm not sure but I think this is because the div containing "upload" button is hidden by jquery tabs(). In that context, it seems that parentNode can be null, which is not tested in the recursivity of isVisible() :

`ss.isVisible = function( elem ) {
"use strict";

if ( elem.nodeType !== 1 || elem == document.body ) {
    elem = null;
    return true;
}

if ( elem.offsetWidth > 0 ||
     elem.offsetHeight > 0 ||
     ss.getStyle( elem, 'display' ).toLowerCase() != 'none' )
{
    return ss.isVisible( **elem.parentNode** );
}

elem = null;
return false;

};
`

Thanks for your help.

@LPology
Copy link
Owner

LPology commented Apr 17, 2016

This is a strange one. Even if a parent element is invisible it shouldn't be null, right? The only thing I can think of is to check for elem.parentNode prior to referencing:

ss.isVisible = function( elem ) {
    "use strict";

    if ( !elem ) {
        return false;
    }

    if ( elem.nodeType !== 1 || elem == document.body ) {
        elem = null;
        return true;
    }

    if ( elem.parentNode &&
        ( elem.offsetWidth > 0 ||
         elem.offsetHeight > 0 ||
         ss.getStyle( elem, 'display' ).toLowerCase() != 'none' ) )
    {
        return ss.isVisible( elem.parentNode );
    }

    elem = null;
    return false;
};

I'm about to push an update with this change now (it will be version 2.5.4).

I'm going to close this issue, but if this doesn't fix the problem please re-open the issue and we'll figure out another approach.

@LPology LPology closed this as completed Apr 17, 2016
@RCohenE5Group
Copy link
Author

version 2.5.5 fixed the problem. Thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants