aboutsummaryrefslogtreecommitdiff
path: root/js/tests
diff options
context:
space:
mode:
authorMark Otto <[email protected]>2016-11-26 01:14:55 -0800
committerGitHub <[email protected]>2016-11-26 01:14:55 -0800
commitce31f54c368ec7c073d8a1c2ab063461951f58eb (patch)
tree862203f9b1854e8e9bb17c97b35673c9ca291a48 /js/tests
parentbb6c197d9baeb873ad6aeb4af51632c85187d133 (diff)
parent14ec4fdfc10a965477314078c1a9531a1d02fb8f (diff)
downloadbootstrap-ce31f54c368ec7c073d8a1c2ab063461951f58eb.tar.xz
bootstrap-ce31f54c368ec7c073d8a1c2ab063461951f58eb.zip
Merge pull request #19058 from Johann-S/carouselInput
Carousel - Do not prevent on keydown for input and textarea
Diffstat (limited to 'js/tests')
-rw-r--r--js/tests/unit/carousel.js32
1 files changed, 32 insertions, 0 deletions
diff --git a/js/tests/unit/carousel.js b/js/tests/unit/carousel.js
index 033ccfd6c..7fc4f4529 100644
--- a/js/tests/unit/carousel.js
+++ b/js/tests/unit/carousel.js
@@ -759,4 +759,36 @@ $(function () {
.bootstrapCarousel('prev')
assert.strictEqual($carousel.find('.carousel-item.active').attr('id'), 'one', 'carousel did not wrap around and stayed on 1st slide')
})
+
+ QUnit.test('should not prevent keydown for inputs and textareas', function (assert) {
+ assert.expect(2)
+ var templateHTML = '<div id="myCarousel" class="carousel" data-interval="false">'
+ + '<div class="carousel-inner">'
+ + '<div id="first" class="carousel-item">'
+ + '<input type="text" id="inputText" />'
+ + '</div>'
+ + '<div id="second" class="carousel-item active">'
+ + '<textarea id="txtArea"></textarea>'
+ + '</div>'
+ + '</div>'
+ + '</div>'
+ var $template = $(templateHTML)
+ var done = assert.async()
+ $template.appendTo('#qunit-fixture')
+ var $inputText = $template.find('#inputText')
+ var $textArea = $template.find('#txtArea')
+ $template.bootstrapCarousel()
+
+ var eventKeyDown = $.Event('keydown', { which: 65 }) // 65 for "a"
+ $inputText.on('keydown', function (event) {
+ assert.strictEqual(event.isDefaultPrevented(), false)
+ })
+ $inputText.trigger(eventKeyDown)
+
+ $textArea.on('keydown', function (event) {
+ assert.strictEqual(event.isDefaultPrevented(), false)
+ done()
+ })
+ $textArea.trigger(eventKeyDown)
+ })
})