mirror of
https://github.com/jquery/jquery-ui.git
synced 2024-11-21 11:04:24 +00:00
Widget: Remove core event/alias and deprecated module dependencies
This commit is contained in:
parent
24f1ce9ea0
commit
e543253468
@ -139,7 +139,7 @@
|
||||
});
|
||||
|
||||
// click to toggle enabled/disabled
|
||||
$( "#disable" ).click(function() {
|
||||
$( "#disable" ).on( "click", function() {
|
||||
// use the custom selector created for each widget to find all instances
|
||||
// all instances are toggled together, so we can check the state from the first
|
||||
if ( $( ":custom-colorize" ).colorize( "option", "disabled" ) ) {
|
||||
@ -150,7 +150,7 @@
|
||||
});
|
||||
|
||||
// click to set options after initialization
|
||||
$( "#green" ).click( function() {
|
||||
$( "#green" ).on( "click", function() {
|
||||
$( ":custom-colorize" ).colorize( "option", {
|
||||
red: 64,
|
||||
green: 250,
|
||||
|
@ -131,7 +131,7 @@ test( "jQuery usage", function() {
|
||||
|
||||
shouldCreate = true;
|
||||
elem = $( "<div>" )
|
||||
.bind( "testwidgetcreate", function() {
|
||||
.on( "testwidgetcreate", function() {
|
||||
ok( shouldCreate, "create event triggered on instantiation" );
|
||||
})
|
||||
.testWidget();
|
||||
@ -902,7 +902,7 @@ test( "_on() with delegate", function() {
|
||||
_create: function() {
|
||||
var uuid = this.uuid;
|
||||
this.element = {
|
||||
bind: function( event, handler ) {
|
||||
on: function( event, handler ) {
|
||||
equal( event, "click.testWidget" + uuid );
|
||||
ok( $.isFunction(handler) );
|
||||
},
|
||||
@ -910,7 +910,7 @@ test( "_on() with delegate", function() {
|
||||
};
|
||||
this.widget = function() {
|
||||
return {
|
||||
delegate: function( selector, event, handler ) {
|
||||
on: function( event, selector, handler ) {
|
||||
equal( selector, "a" );
|
||||
equal( event, "click.testWidget" + uuid );
|
||||
ok( $.isFunction(handler) );
|
||||
@ -923,7 +923,7 @@ test( "_on() with delegate", function() {
|
||||
});
|
||||
this.widget = function() {
|
||||
return {
|
||||
delegate: function( selector, event, handler ) {
|
||||
on: function( event, selector, handler ) {
|
||||
equal( selector, "form fieldset > input" );
|
||||
equal( event, "change.testWidget" + uuid );
|
||||
ok( $.isFunction(handler) );
|
||||
@ -1005,7 +1005,7 @@ test( "_off() - single event", function() {
|
||||
widget._on( element, { foo: function() {
|
||||
ok( shouldTriggerWidget, "foo called from _on" );
|
||||
}});
|
||||
element.bind( "foo", function() {
|
||||
element.on( "foo", function() {
|
||||
ok( shouldTriggerOther, "foo called from bind" );
|
||||
});
|
||||
shouldTriggerWidget = true;
|
||||
@ -1031,7 +1031,7 @@ test( "_off() - multiple events", function() {
|
||||
ok( shouldTriggerWidget, "bar called from _on" );
|
||||
}
|
||||
});
|
||||
element.bind( "foo bar", function( event ) {
|
||||
element.on( "foo bar", function( event ) {
|
||||
ok( shouldTriggerOther, event.type + " called from bind" );
|
||||
});
|
||||
shouldTriggerWidget = true;
|
||||
@ -1059,7 +1059,7 @@ test( "_off() - all events", function() {
|
||||
ok( shouldTriggerWidget, "bar called from _on" );
|
||||
}
|
||||
});
|
||||
element.bind( "foo bar", function( event ) {
|
||||
element.on( "foo bar", function( event ) {
|
||||
ok( shouldTriggerOther, event.type + " called from bind" );
|
||||
});
|
||||
shouldTriggerWidget = true;
|
||||
@ -1152,7 +1152,7 @@ test( "._trigger() - no event, no ui", function() {
|
||||
}
|
||||
});
|
||||
$( document ).add( "#widget-wrapper" ).add( "#widget" )
|
||||
.bind( "testwidgetfoo", function( event, ui ) {
|
||||
.on( "testwidgetfoo", function( event, ui ) {
|
||||
deepEqual( ui, {}, "empty ui hash passed" );
|
||||
handlers.push( this );
|
||||
});
|
||||
@ -1165,7 +1165,7 @@ test( "._trigger() - no event, no ui", function() {
|
||||
"callback"
|
||||
], "event bubbles and then invokes callback" );
|
||||
|
||||
$( document ).unbind( "testwidgetfoo" );
|
||||
$( document ).off( "testwidgetfoo" );
|
||||
});
|
||||
|
||||
test( "._trigger() - cancelled event", function() {
|
||||
@ -1180,7 +1180,7 @@ test( "._trigger() - cancelled event", function() {
|
||||
ok( true, "callback invoked even if event is cancelled" );
|
||||
}
|
||||
})
|
||||
.bind( "testwidgetfoo", function() {
|
||||
.on( "testwidgetfoo", function() {
|
||||
ok( true, "event was triggered" );
|
||||
return false;
|
||||
});
|
||||
@ -1227,7 +1227,7 @@ test( "._trigger() - provide event and ui", function() {
|
||||
}, "ui object modified" );
|
||||
}
|
||||
});
|
||||
$( "#widget" ).bind( "testwidgetfoo", function( event, ui ) {
|
||||
$( "#widget" ).on( "testwidgetfoo", function( event, ui ) {
|
||||
equal( event.originalEvent, originalEvent, "original event object passed" );
|
||||
deepEqual( ui, {
|
||||
foo: "bar",
|
||||
@ -1238,7 +1238,7 @@ test( "._trigger() - provide event and ui", function() {
|
||||
}, "ui hash passed" );
|
||||
ui.foo = "notbar";
|
||||
});
|
||||
$( "#widget-wrapper" ).bind( "testwidgetfoo", function( event, ui ) {
|
||||
$( "#widget-wrapper" ).on( "testwidgetfoo", function( event, ui ) {
|
||||
equal( event.originalEvent, originalEvent, "original event object passed" );
|
||||
deepEqual( ui, {
|
||||
foo: "notbar",
|
||||
@ -1285,7 +1285,7 @@ test( "._trigger() - array as ui", function() {
|
||||
this._trigger( "foo", null, [ ui, extra ] );
|
||||
}
|
||||
});
|
||||
$( "#widget" ).bind( "testwidgetfoo", function( event, ui, extra ) {
|
||||
$( "#widget" ).on( "testwidgetfoo", function( event, ui, extra ) {
|
||||
deepEqual( ui, {
|
||||
foo: "bar",
|
||||
baz: {
|
||||
@ -1328,7 +1328,7 @@ test( "._trigger() - instance as element", function() {
|
||||
deepEqual( ui, { foo: "bar" }, "ui object passed to callback" );
|
||||
}
|
||||
});
|
||||
$( instance ).bind( "testwidgetfoo", function( event, ui ) {
|
||||
$( instance ).on( "testwidgetfoo", function( event, ui ) {
|
||||
equal( event.type, "testwidgetfoo", "event object passed to event handler" );
|
||||
deepEqual( ui, { foo: "bar" }, "ui object passed to event handler" );
|
||||
});
|
||||
|
12
ui/widget.js
12
ui/widget.js
@ -313,14 +313,14 @@ $.Widget.prototype = {
|
||||
// we can probably remove the unbind calls in 2.0
|
||||
// all event bindings should go through this._on()
|
||||
this.element
|
||||
.unbind( this.eventNamespace )
|
||||
.off( this.eventNamespace )
|
||||
.removeData( this.widgetFullName );
|
||||
this.widget()
|
||||
.unbind( this.eventNamespace )
|
||||
.off( this.eventNamespace )
|
||||
.removeAttr( "aria-disabled" );
|
||||
|
||||
// clean up events and states
|
||||
this.bindings.unbind( this.eventNamespace );
|
||||
this.bindings.off( this.eventNamespace );
|
||||
},
|
||||
_destroy: $.noop,
|
||||
|
||||
@ -535,9 +535,9 @@ $.Widget.prototype = {
|
||||
eventName = match[ 1 ] + instance.eventNamespace,
|
||||
selector = match[ 2 ];
|
||||
if ( selector ) {
|
||||
delegateElement.delegate( selector, eventName, handlerProxy );
|
||||
delegateElement.on( eventName, selector, handlerProxy );
|
||||
} else {
|
||||
element.bind( eventName, handlerProxy );
|
||||
element.on( eventName, handlerProxy );
|
||||
}
|
||||
} );
|
||||
},
|
||||
@ -545,7 +545,7 @@ $.Widget.prototype = {
|
||||
_off: function( element, eventName ) {
|
||||
eventName = ( eventName || "" ).split( " " ).join( this.eventNamespace + " " ) +
|
||||
this.eventNamespace;
|
||||
element.unbind( eventName ).undelegate( eventName );
|
||||
element.off( eventName ).off( eventName );
|
||||
|
||||
// Clear the stack to avoid memory leaks (#10056)
|
||||
this.bindings = $( this.bindings.not( element ).get() );
|
||||
|
Loading…
Reference in New Issue
Block a user