Skip to content

Commit 12b47dc

Browse files
committed
Widget factory: Fixed $4266 - Add custom selectors for widgets.
1 parent 2b8109e commit 12b47dc

1 file changed

Lines changed: 9 additions & 2 deletions

File tree

ui/ui.core.js

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -217,9 +217,16 @@ function getter(namespace, plugin, method, args) {
217217
}
218218

219219
$.widget = function(name, prototype) {
220-
var namespace = name.split(".")[0];
220+
var namespace = name.split(".")[0],
221+
fullName;
221222
name = name.split(".")[1];
223+
fullName = namespace + '-' + name;
222224

225+
// create selector for plugin
226+
$.expr[':'][fullName] = function(elem) {
227+
return !!$.data(elem, name);
228+
};
229+
223230
// create plugin method
224231
$.fn[name] = function(options) {
225232
var isMethodCall = (typeof options == 'string'),
@@ -259,7 +266,7 @@ $.widget = function(name, prototype) {
259266
this.namespace = namespace;
260267
this.widgetName = name;
261268
this.widgetEventPrefix = $[namespace][name].eventPrefix || name;
262-
this.widgetBaseClass = namespace + '-' + name;
269+
this.widgetBaseClass = fullName;
263270

264271
this.options = $.extend(true, {},
265272
$.widget.defaults,

0 commit comments

Comments
 (0)