@@ -37,7 +37,13 @@ $.widget = function( name, base, prototype ) {
3737
3838 $ [ namespace ] = $ [ namespace ] || { } ;
3939 $ [ namespace ] [ name ] = function ( options , element ) {
40+ // allow instantiation without "new" keyword
41+ if ( ! this . _createWidget ) {
42+ return new $ [ namespace ] [ name ] ( options , element ) ;
43+ }
44+
4045 // allow instantiation without initializing for simple inheritance
46+ // must use "new" keyword (the code above always passes args)
4147 if ( arguments . length ) {
4248 this . _createWidget ( options , element ) ;
4349 }
@@ -97,7 +103,7 @@ $.widget.bridge = function( name, object ) {
97103 if ( instance ) {
98104 instance . option ( options || { } ) . _init ( ) ;
99105 } else {
100- $ . data ( this , name , new object ( options , this ) ) ;
106+ object ( options , this ) ;
101107 }
102108 } ) ;
103109 }
@@ -107,7 +113,13 @@ $.widget.bridge = function( name, object ) {
107113} ;
108114
109115$ . Widget = function ( options , element ) {
116+ // allow instantiation without "new" keyword
117+ if ( ! this . _createWidget ) {
118+ return new $ [ namespace ] [ name ] ( options , element ) ;
119+ }
120+
110121 // allow instantiation without initializing for simple inheritance
122+ // must use "new" keyword (the code above always passes args)
111123 if ( arguments . length ) {
112124 this . _createWidget ( options , element ) ;
113125 }
0 commit comments