Opened 8 months ago

Closed 8 months ago

Last modified 8 months ago

#15019 closed bug (fixed)

Widget instance does not return undefined for empty jQuery collection

Reported by: victor-homyakov Owned by: scottgonzalez
Priority: minor Milestone: 1.12.1
Component: ui.widget Version: 1.12.0
Keywords: Cc:
Blocked by: Blocking:


Current versions of jQuery UI return following values for widget instance:

  • When widget is initialized: widget instance
  • When widget is not initialized: undefined
  • When jQuery collection is empty: empty jQuery collection

This is a bit misleading because as stated in, if the element does not have an associated instance, undefined is returned. I ran into that problem in single-page application, while I was simply checking for non-undefined widget instance before calling widget methods. In case when DOM element is missing, additional check is required.

Change History (2)

comment:1 Changed 8 months ago by scottgonzalez

  • Owner set to scottgonzalez
  • Resolution set to fixed
  • Status changed from new to closed

In 3dd8a09:

Widget: instance() should return undefined for empty sets

Fixes #15019

comment:2 Changed 8 months ago by scottgonzalez

  • Milestone changed from none to 1.12.1
Note: See TracTickets for help on using tickets.