Opened 8 months ago

Last modified 8 months ago

#15331 new bug

Additional variable check related to: Uncaught TypeError: Cannot read property 'value' of undefined

Reported by: FinexLy Exchange Owned by:
Priority: minor Milestone: none
Component: ui.autocomplete Version: 1.12.1
Keywords: Cc:
Blocked by: Blocking:

Description

Regarding the error, which is very common in my application I would like to request a little update, the error is: Uncaught TypeError: Cannot read property 'value' of undefined jquery-ui.js:2971


Current Code:

// Announce the value in the liveRegion
label = ui.item.attr("aria-label") || item.value;
if (label && $.trim(label).length) {
    this.liveRegion.children().hide();
    $("<div>").text(label).appendTo(this.liveRegion);
}

Can you please update it to:

...

// Announce the value in the liveRegion
if(typeof item !== "undefined") {
    label = ui.item.attr("aria-label") || item.value;
    if (label && $.trim(label).length) {
        this.liveRegion.children().hide();
        $("<div>").text(label).appendTo(this.liveRegion);
    }
}

Change History (1)

comment:1 Changed 8 months ago by FinexLy Exchange

It is so simple, that doesn't even need an example/test.

Note: See TracTickets for help on using tickets.