@@ -37,7 +37,13 @@ $.widget = function( name, base, prototype ) {
37
37
38
38
$ [ namespace ] = $ [ namespace ] || { } ;
39
39
$ [ namespace ] [ name ] = function ( options , element ) {
40
+ // allow instantiation without "new" keyword
41
+ if ( ! this . _createWidget ) {
42
+ return new $ [ namespace ] [ name ] ( options , element ) ;
43
+ }
44
+
40
45
// allow instantiation without initializing for simple inheritance
46
+ // must use "new" keyword (the code above always passes args)
41
47
if ( arguments . length ) {
42
48
this . _createWidget ( options , element ) ;
43
49
}
@@ -97,7 +103,7 @@ $.widget.bridge = function( name, object ) {
97
103
if ( instance ) {
98
104
instance . option ( options || { } ) . _init ( ) ;
99
105
} else {
100
- $ . data ( this , name , new object ( options , this ) ) ;
106
+ object ( options , this ) ;
101
107
}
102
108
} ) ;
103
109
}
@@ -107,7 +113,13 @@ $.widget.bridge = function( name, object ) {
107
113
} ;
108
114
109
115
$ . Widget = function ( options , element ) {
116
+ // allow instantiation without "new" keyword
117
+ if ( ! this . _createWidget ) {
118
+ return new $ [ namespace ] [ name ] ( options , element ) ;
119
+ }
120
+
110
121
// allow instantiation without initializing for simple inheritance
122
+ // must use "new" keyword (the code above always passes args)
111
123
if ( arguments . length ) {
112
124
this . _createWidget ( options , element ) ;
113
125
}
0 commit comments