Skip to content

Commit 4d6c6c2

Browse files
committed
Button: Remove form reset handling
1 parent e3e4f4a commit 4d6c6c2

File tree

3 files changed

+10
-39
lines changed

3 files changed

+10
-39
lines changed

tests/unit/button/button.html

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,15 +12,17 @@
1212

1313
<div id="qunit"></div>
1414
<div id="qunit-fixture">
15+
<form id="form1">
16+
<div><button id="button">Label</button></div>
1517

16-
<div><button id="button">Label</button></div>
18+
<div><input id="submit" type="submit" value="Label"></div>
19+
</form>
1720

18-
<div><input id="submit" type="submit" value="Label"></div>
19-
20-
<button id="button-disabled" disabled>Button</button>
21-
22-
<a href="#" id="anchor-button">Anchor Button</a>
21+
<form id="form2">
22+
<button id="button-disabled" disabled>Button</button>
2323

24+
<a href="#" id="anchor-button">Anchor Button</a>
25+
</form>
2426
</div>
2527
</body>
2628
</html>

tests/unit/button/options.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ test( "label, explicit value", function() {
8888

8989
test( "label, default, with input type submit", function() {
9090
expect( 2 );
91-
var button = $( "#submit" ).button()
91+
var button = $( "#submit" ).button();
9292

9393
deepEqual( button.val(), "Label" );
9494
deepEqual( button.button( "option", "label" ), "Label" );

ui/button.js

Lines changed: 1 addition & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -37,20 +37,6 @@
3737
}
3838
}( function( $ ) {
3939

40-
var formResetHandler = function() {
41-
var form = $( this );
42-
43-
// Wait for the form reset to actually happen before refreshing
44-
setTimeout( function() {
45-
46-
// We find .ui-button first, then filter by :ui-button,
47-
// because widget pseudo selectors are very very slow, but
48-
// we need to filter out CSS-only buttons
49-
form.find( ".ui-button" ).filter( ":ui-button" ).button( "refresh" );
50-
} );
51-
},
52-
forms = {};
53-
5440
$.widget( "ui.button", {
5541
version: "@VERSION",
5642
defaultElement: "<button>",
@@ -85,18 +71,6 @@ $.widget( "ui.button", {
8571
},
8672

8773
_create: function() {
88-
this.formElement = $( this.element[ 0 ].form ).uniqueId();
89-
this.formId = this.formElement.attr( "id" );
90-
91-
forms[ this.formId ] = forms[ this.formId ] || 0;
92-
93-
// We don't use _on and _off here because we want all the checkboxes in the same form to use
94-
// single handler which handles all the checkboxradio widgets in the form
95-
if ( forms[ this.formId ] === 0 ) {
96-
this.formElement.on( "reset." + this.widgetFullName, formResetHandler );
97-
}
98-
forms[ this.formId ]++;
99-
10074
if ( !this.option.showLabel & !this.options.icon ) {
10175
this.options.showLabel = true;
10276
}
@@ -182,7 +156,7 @@ $.widget( "ui.button", {
182156
this.icon[ this._getAttachMethod( true, icon ? undefined : value ) ]( this.iconSpace );
183157
} else {
184158
this._addClass( this.icon, null, "ui-widget-icon-block" );
185-
if( this.iconSpace ) {
159+
if ( this.iconSpace ) {
186160
this.iconSpace.remove();
187161
}
188162
}
@@ -200,11 +174,6 @@ $.widget( "ui.button", {
200174
if ( !this.hasTitle ) {
201175
this.element.removeAttr( "title" );
202176
}
203-
204-
forms[ this.formId ]--;
205-
if ( forms[ this.formId ] === 0 ) {
206-
this.formElement.off( "reset." + this.widgetFullName, formResetHandler );
207-
}
208177
},
209178

210179
_getAttachMethod: function( space, position ) {

0 commit comments

Comments
 (0)