Widget instance does not return undefined for empty jQuery collection
|Reported by:||victor-homyakov||Owned by:||scottgonzalez|
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 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.