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

Commit

Permalink
Button: Reference wrapper by its correct name in _destroy()
Browse files Browse the repository at this point in the history
(cherry picked from commit 7d361e9)

Closes gh-7491
Fixes gh-7490
  • Loading branch information
Gabriel Schulhof committed Jul 30, 2014
1 parent 445ff20 commit e8c0118
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 2 deletions.
4 changes: 2 additions & 2 deletions js/widgets/forms/button.js
Expand Up @@ -78,8 +78,8 @@ $.widget( "mobile.button", {
},

_destroy: function() {
this.element.insertBefore( this.button );
this.button.remove();
this.element.insertBefore( this.wrapper );
this.wrapper.remove();
},

_getIconClasses: function( options ) {
Expand Down
11 changes: 11 additions & 0 deletions tests/unit/button/button_core.js
Expand Up @@ -54,4 +54,15 @@
deepEqual( button.button( "option", "disabled" ), true, "option disabled is now true" );
});

test( "Destroying a button works correctly", function() {
var button = $( "<input type='button' value='Destroy Test'>" ),
container = $( "#destroy-test-container" ).append( button ),
pristineDOM = container.clone();

button.button().button( "destroy" );

deepEqual( $.testHelper.domEqual( container, pristineDOM ), true,
"_destroy() leaves DOM unmodified" );
});

})( jQuery );
1 change: 1 addition & 0 deletions tests/unit/button/index.html
Expand Up @@ -65,6 +65,7 @@
<button id="contains-html">Supports <sup>phrasing content</sup></button>
<input type="button" id="val-contains-html" value="<fake markup>"/>
<input type="button" id="disabled-state" value="ABC"/>
<div id="destroy-test-container"></div>
</div>
</div>
</body>
Expand Down

0 comments on commit e8c0118

Please sign in to comment.