Skip to content
This repository was archived by the owner on Oct 8, 2021. It is now read-only.

Commit e8c0118

Browse files
author
Gabriel Schulhof
committed
Button: Reference wrapper by its correct name in _destroy()
(cherry picked from commit 7d361e9) Closes gh-7491 Fixes gh-7490
1 parent 445ff20 commit e8c0118

File tree

3 files changed

+14
-2
lines changed

3 files changed

+14
-2
lines changed

js/widgets/forms/button.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -78,8 +78,8 @@ $.widget( "mobile.button", {
7878
},
7979

8080
_destroy: function() {
81-
this.element.insertBefore( this.button );
82-
this.button.remove();
81+
this.element.insertBefore( this.wrapper );
82+
this.wrapper.remove();
8383
},
8484

8585
_getIconClasses: function( options ) {

tests/unit/button/button_core.js

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,4 +54,15 @@
5454
deepEqual( button.button( "option", "disabled" ), true, "option disabled is now true" );
5555
});
5656

57+
test( "Destroying a button works correctly", function() {
58+
var button = $( "<input type='button' value='Destroy Test'>" ),
59+
container = $( "#destroy-test-container" ).append( button ),
60+
pristineDOM = container.clone();
61+
62+
button.button().button( "destroy" );
63+
64+
deepEqual( $.testHelper.domEqual( container, pristineDOM ), true,
65+
"_destroy() leaves DOM unmodified" );
66+
});
67+
5768
})( jQuery );

tests/unit/button/index.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@
6565
<button id="contains-html">Supports <sup>phrasing content</sup></button>
6666
<input type="button" id="val-contains-html" value="<fake markup>"/>
6767
<input type="button" id="disabled-state" value="ABC"/>
68+
<div id="destroy-test-container"></div>
6869
</div>
6970
</div>
7071
</body>

0 commit comments

Comments
 (0)