Skip to content

TypeError: undefined is not an object – gallery.length on undefined in show() function #248

@czirkoszoltan

Description

@czirkoszoltan

Currently the show() function looks like this:

    /**
     * Move the gallery to a specific index
     * @param `index` {number} - the position of the image
     * @param `gallery` {array} - gallery which should be opened, if omitted assumes the currently opened one
     * @return {boolean} - true on success or false if the index is invalid
     */
    function show(index, gallery) {
        if (!isOverlayVisible && index >= 0 && index < gallery.length) {
            prepareOverlay(gallery, options);
            showOverlay(index);
            return true;        

The comment says that the gallery argument can be omitted. Still, the condition takes gallery.length, which is a TypeError if gallery==undefined. The other show...() functions (from line 603 to 627) all use show() with one argument only.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions