JQuery UI - Uncaught TypeError: Cannot read property 'value' of undefined

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);
}


Updated Code :  

// 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);
  }
}