});
test( "$.widget.bridge()", function() {
- expect( 10 );
+ expect( 14 );
var instance, ret,
elem = $( "<div>" );
},
getter: function() {
return "qux";
+ },
+ option: function( options ) {
+ deepEqual( options, {} );
}
});
ret = elem.testWidget( "getter" );
equal( ret, "qux", "getter returns value" );
+
+ elem.testWidget();
+ ok( true, "_init is optional" );
+
+ TestWidget.prototype._init = function() {
+ ok( "_init", "_init now exists, so its called" );
+ };
+ elem.testWidget();
});
test( "$.widget.bridge() - widgetFullName", function() {
this.each(function() {
var instance = $.data( this, fullName );
if ( instance ) {
- instance.option( options || {} )._init();
+ instance.option( options || {} );
+ if ( instance._init ) {
+ instance._init();
+ }
} else {
$.data( this, fullName, new object( options, this ) );
}