Permalink
Browse files

Textinput: Only _destroy() clear button when present

Closes gh-7568
Fixes gh-7567
  • Loading branch information...
gabrielschulhof committed Aug 27, 2014
1 parent e412102 commit c6ba792038a571f10c1f831227ebaa4d0de307b0
Showing with 17 additions and 1 deletion.
  1. +3 −1 js/widgets/forms/clearButton.js
  2. +4 −0 tests/unit/textinput/index.html
  3. +10 −0 tests/unit/textinput/textinput_core.js
@@ -127,7 +127,9 @@ define( [
_destroy: function() {
this._super();
this._destroyClear();
if ( this.options.clearBtn ) {
this._destroyClear();
}
}
});
@@ -8,6 +8,7 @@
<script src="../../../external/requirejs/require.js"></script>
<script src="../../../js/requirejs.config.js"></script>
<script src="../../../js/jquery.tag.inserter.js"></script>
<script src="../../jquery.setNameSpace.js"></script>
<script src="../../../external/qunit/qunit.js"></script>
<script src="../../../tests/jquery.testHelper.js"></script>
<script src="../../../tests/jquery.setNameSpace.js"></script>
@@ -70,6 +71,9 @@
<input type="text" id="focus-class-test-for-input"></input>
<textarea id="focus-class-test-for-textarea"></textarea>
<input id="injection-test" data-nstest-clear-btn="true" data-nstest-clear-btn-text="'>a<script>$.clearBtnTextScriptInjected = true;</script>bc</a><a'">
<div id="destroy-test-container">
<input type="text" id="destroy-test" data-nstest-role="none"></input>
</div>
</div>
</body>
</html>
@@ -171,4 +171,14 @@
"no script was injected via clearBtnText option" );
});
test( "textinput is destroyed correctly", function() {
var originalDOM = $( "#destroy-test-container" ).clone(),
entry = $( "#destroy-test" );
entry.textinput().textinput( "destroy" );
deepEqual( $.testHelper.domEqual( originalDOM, $( "#destroy-test-container" ) ), true,
"Original DOM is restored after textinput destruction" );
});
})(jQuery);

0 comments on commit c6ba792

Please sign in to comment.