Skip to content

Commit c6ba792

Browse files
author
Gabriel Schulhof
committed
Textinput: Only _destroy() clear button when present
Closes jquery-archivegh-7568 Fixes jquery-archivegh-7567
1 parent e412102 commit c6ba792

File tree

3 files changed

+17
-1
lines changed

3 files changed

+17
-1
lines changed

js/widgets/forms/clearButton.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,9 @@ define( [
127127

128128
_destroy: function() {
129129
this._super();
130-
this._destroyClear();
130+
if ( this.options.clearBtn ) {
131+
this._destroyClear();
132+
}
131133
}
132134

133135
});

tests/unit/textinput/index.html

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
<script src="../../../external/requirejs/require.js"></script>
99
<script src="../../../js/requirejs.config.js"></script>
1010
<script src="../../../js/jquery.tag.inserter.js"></script>
11+
<script src="../../jquery.setNameSpace.js"></script>
1112
<script src="../../../external/qunit/qunit.js"></script>
1213
<script src="../../../tests/jquery.testHelper.js"></script>
1314
<script src="../../../tests/jquery.setNameSpace.js"></script>
@@ -70,6 +71,9 @@
7071
<input type="text" id="focus-class-test-for-input"></input>
7172
<textarea id="focus-class-test-for-textarea"></textarea>
7273
<input id="injection-test" data-nstest-clear-btn="true" data-nstest-clear-btn-text="'>a<script>$.clearBtnTextScriptInjected = true;</script>bc</a><a'">
74+
<div id="destroy-test-container">
75+
<input type="text" id="destroy-test" data-nstest-role="none"></input>
76+
</div>
7377
</div>
7478
</body>
7579
</html>

tests/unit/textinput/textinput_core.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -171,4 +171,14 @@
171171
"no script was injected via clearBtnText option" );
172172
});
173173

174+
test( "textinput is destroyed correctly", function() {
175+
var originalDOM = $( "#destroy-test-container" ).clone(),
176+
entry = $( "#destroy-test" );
177+
178+
entry.textinput().textinput( "destroy" );
179+
180+
deepEqual( $.testHelper.domEqual( originalDOM, $( "#destroy-test-container" ) ), true,
181+
"Original DOM is restored after textinput destruction" );
182+
});
183+
174184
})(jQuery);

0 commit comments

Comments
 (0)