Skip to main content

Search and Top Navigation

#15019 closed bug (fixed)

Opened August 02, 2016 10:28AM UTC

Closed August 04, 2016 01:05PM UTC

Last modified August 04, 2016 01:05PM UTC

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:
Description

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

https://jsfiddle.net/gtmbwyb9/

This is a bit misleading because as stated in https://api.jqueryui.com/jQuery.widget/#method-instance, 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.

Attachments (0)
Change History (2)

Changed August 04, 2016 01:05PM UTC by scottgonzalez comment:1

owner: → scottgonzalez
resolution: → fixed
status: newclosed

In [changeset:"3dd8a09b441d65445f2b6a7c73e72af65445d5da" 3dd8a09]:

#!CommitTicketReference repository="" revision="3dd8a09b441d65445f2b6a7c73e72af65445d5da"
Widget:  should return  for empty sets

Fixes #15019

Changed August 04, 2016 01:05PM UTC by scottgonzalez comment:2

milestone: none1.12.1