Permalink
Browse files

Button: Reference wrapper by its correct name in _destroy()

(cherry picked from commit 7d361e9)

Closes gh-7491
Fixes gh-7490
  • Loading branch information...
1 parent 445ff20 commit e8c0118bdd9d9a820f89b3da02e0d66cdf63a4d6 @gabrielschulhof gabrielschulhof committed Jun 11, 2014
Showing with 14 additions and 2 deletions.
  1. +2 −2 js/widgets/forms/button.js
  2. +11 −0 tests/unit/button/button_core.js
  3. +1 −0 tests/unit/button/index.html
@@ -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 ) {
@@ -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 );
@@ -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>

0 comments on commit e8c0118

Please sign in to comment.